Page MenuHomePhabricator

Correct Wikidata IDs not available from Javascript of Commons categories
Open, Needs TriagePublic

Description

In order to work around the fact that you can't create interwiki links to both Commons categories and gallery pages from a single Wikidata item, people have started creating category items on Wikidata (e.g. Category:Pizzas) and linking Commons categories to them instead of to the main conceptual items (e.g. Pizza). While this has improved the interwiki links (via some voodoo with the "category's main topic" property), it has made utilizing Wikidata from gadgets, userscripts, and client-side MediaWiki code even more difficult.

When I try to utilize the wgWikibaseItemId config variable from a category page, for example Category:Pizzas, I get one of the following results:

  • Nothing, if the item (e.g. Pizza) is linked to the gallery page instead of the category and there is no category item.
  • A useless item ID for the category item (e.g. Category:Pizzas) which has none of the actual data for the item (e.g. Pizza).
  • The correct Wikidata ID for the corresponding Wikidata item (e.g. Pizza).

Thus it's impossible to make any effective use of Wikidata from the client-side on Category pages (without making multiple round-trip API queries to Wikidata).