Page MenuHomePhabricator

It should be possible to get entity id from page title
Closed, ResolvedPublic


<DanielK_WMDE> lazowik: EntityPerPage should provide a function for looking up the ID for a given Title; and/or there should be an inverse of the EntityTitleLookup interface.

This is needed e.g. for showing concept and export urls on action=info



Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 3:24 AM
bzimport set Reference to bz65507.
bzimport added a subscriber: Unknown Object (MLST).
Lazowik created this task.May 19 2014, 8:58 PM

What should be implemented? Function in EntityPerPage or new interface?
Also EntityPerPage has two related todos:
@todo: Combine with the EntityTitleLookup interface?
@todo: At least add a way to get page IDs!

It's clear that we should have an getEntityIdForTitle function somewhere, but it's not clear to me where it should reside, and what the exact signature should be (in the future, we may have more than one entity on a page).

For now though, I suggest to put that method into the EntityTitleLookup interface, and implemented it in EntityContentFactory (which implements EntityTitleLookup) like this:

$id = $idParser->parser( $title->getText() )

This isn't 100% future proof, but will work for now. This should make it easy enough to change the logic later.

Change 134727 had a related patch set uploaded by Michał Łazowik:
Add getting entity id from page title

Change 134727 abandoned by Michał Łazowik:
Introduce EntityIdLookup

Need to figure out a good place for that and do a bit of refactoring beforehand.

Lydia_Pintscher removed a subscriber: Unknown Object (MLST).
Lydia_Pintscher removed a subscriber: Unknown Object (MLST).
Rical added a subscriber: Rical.Dec 12 2014, 8:13 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptAug 22 2015, 2:31 PM
hoo closed this task as Resolved.Jan 3 2016, 7:14 AM
hoo claimed this task.
hoo added a subscriber: hoo.

Wikibase\Store\EntityIdLookup::getEntityIdForTitle can do this.

Rical added a comment.Apr 24 2016, 9:35 AM

How to use that in Scribunto ? I search in many places but don't find it.

@Rical I assume you want a way to find the wikidata item connected to a given page (title), not the item on that page (which only makes sense on the repo). That's a very different task. I agree that it would be useful to have a way to do this in Lua. Please open a separate ticket about that.

Rical removed a subscriber: Rical.Jul 21 2017, 9:41 AM