Page MenuHomePhabricator

Update the code behind the Wikimedia Commons link in the sidebar to use P910 and P1754 instead of P373
Open, HighPublic8 Estimated Story Points

Description

Main components:

  • Wikimedia Badges (a MediaWiki extension)

Problem:
The sidebar link to Wikimedia Commons on various Wikipedias currently uses P373 ("commons category"). It would be better to use the interwiki sitelinks to Commons instead.

This is one of the blockers for the eventual deletion of P373 ("commons category") from Wikidata - see the ongoing discussion at https://www.wikidata.org/wiki/Wikidata:Properties_for_deletion#Property:P373

Solution:
To use the interwiki sitelinks to Commons the logic would be:

  1. If there is a sitelink to Commons in the attached Wikidata item, use that (optional: unless it is to a gallery page)
  2. If there is a P910 ("topic's main category") value, follow that to the category item and use the sitelink to Commons from there
  3. If there is a P1754 ("category related to list") value, follow that to the category item and use the sitelink to Commons from there
  4. If there is a P373 ("commons category") value use this as a last fallback
  5. Otherwise, display nothing.

This follows the logic of the "_getCommonslink" function of https://commons.wikimedia.org/wiki/Module:WikidataIB - which is used to display the links in https://en.wikipedia.org/wiki/Template:Commons_category .

Notes:

  • As this is specific code used for the Wikimedia projects only, it should probably sit in the Wikimedia Badges extension, like the current P373 code (see T94989).
  • The exact logic for getting “the” P910/P1754 value is the same as in the current P373 code (first string-valued best-rank statement).

Acceptance criteria:

  • This works as described (see "solution").
  • This needs to be able to cope with P373 being deleted without breaking things (and ideally it should be easy to remove the P373 fallback in that case).

Community communication:

  • Announce to the community in our wiki summary while we work on it.
  • Announce on project chat / let Mike announce.

Event Timeline

@Lydia_Pintscher Is this within WMDE's scope, or WMF? It would be nice to have this actioned at some point.

Anyone? There are quite a few commons links that aren't being displayed because the logic here hasn't been updated.

@Jdlrobson I saw you were working on the sidebar recently (for the language vs. other sites order), is this something you/your team would be interested in?

@Mike_Peel we've been working on the architecture of the sidebar not consumers like this. My team doesn't have much knowledge of the Wikidata extension or have it setup.

Without understanding this code is this not simply a config change here ?:
https://gerrit.wikimedia.org/g/operations/mediawiki-config/+/aac5a018905bc07c834af5f310d440ea92613c71/wmf-config/InitialiseSettings.php#21916

@Jdlrobson I think part of it is removing P 373 from that config, and that alone would be a good step forward. However, the other part is to follow P 910/P 1754 items through to a different Wikidata item, and to fetch the Commons sitelink from that - and that's probably more complicated/requires code change rather than just a config change.

If it's not in your team's scope, can you suggest anyone who might be able to look into it? It's been stuck here for a while now, and it's fairly high priority if we want to get rid of P 373 on Wikidata at some point soon.

(Sorry, I don't know how to ping you in reply without re-adding you as a subscriber!)

Because this is Wikibase it suggests WMDE Engineering is the team to look at this.
https://www.mediawiki.org/wiki/Developers/Maintainers

Thanks for the ping, we will have a look more in details and come back to you.

Manuel updated the task description. (Show Details)
Manuel updated the task description. (Show Details)

Hi @Mike_Peel! Should we include P373 as a last fallback (until it is removed)?

Hi @Mike_Peel! Should we include P373 as a last fallback (until it is removed)?

Thanks for working on this! I think for now, P373 should be a last fallback - but it would be good if it could be coded in such a way that it could cope with P373 being deleted (if it is in the future) without breaking things, and/or be easy to remove the P373 fallback.

Addshore set the point value for this task to 8.

(optional: unless it is to a gallery page)

I’m going to boldly skip this part because it’s not easy to implement – on other client wikis we have no ideas whether e.g. Artwork:Spiegelfaltung is a gallery page or not, since we don’t know if “Artwork” is a namespace on Commons.

(optional: unless it is to a gallery page)

I’m going to boldly skip this part because it’s not easy to implement – on other client wikis we have no ideas whether e.g. Artwork:Spiegelfaltung is a gallery page or not, since we don’t know if “Artwork” is a namespace on Commons.

To clarify, this was for cases like https://commons.wikimedia.org/wiki/Lagos,_Nigeria - where we have the sitelink to Commons mainspace in the Wikidata topic item (Q8673), and to the Commons category (here, https://commons.wikimedia.org/wiki/Category:Lagos,_Nigeria ) from the Wikidata category item (Q7486765). The sitelinks *should* really only be used for Main or Category items, so this should be fairly simple to include, but no objections if just using sitelinks that start with 'Category:' is easier!

I’m not sure what you mean… right now I’m using any sitelink, without looking at its title, and only fall back to the topic’s main category statement (and then other statements etc.) if the item has on Commons sitelink at all. Is that not what’s supposed to happen?

Change 720972 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/WikimediaBadges@master] Add strict types

https://gerrit.wikimedia.org/r/720972

Change 720973 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/WikimediaBadges@master] Update logic for Wikimedia Commons sitelink

https://gerrit.wikimedia.org/r/720973

I’m not sure what you mean… right now I’m using any sitelink, without looking at its title, and only fall back to the topic’s main category statement (and then other statements etc.) if the item has on Commons sitelink at all. Is that not what’s supposed to happen?

OK, that sounds fine - in that case, it will link to galleries, which is fine. Thanks for working on this!

Change 721305 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[operations/mediawiki-config@master] Add new WikimediaBadges config

https://gerrit.wikimedia.org/r/721305

Change 721305 merged by jenkins-bot:

[operations/mediawiki-config@master] Add new WikimediaBadges config

https://gerrit.wikimedia.org/r/721305

Mentioned in SAL (#wikimedia-operations) [2021-09-16T11:09:45Z] <lucaswerkmeister-wmde@deploy1002> Synchronized wmf-config/InitialiseSettings.php: Config: [[gerrit:721305|Add new WikimediaBadges config (T232927)]] (1/2) (duration: 01m 05s)

Mentioned in SAL (#wikimedia-operations) [2021-09-16T11:11:18Z] <lucaswerkmeister-wmde@deploy1002> Synchronized wmf-config/InitialiseSettings-labs.php: Config: [[gerrit:721305|Add new WikimediaBadges config (T232927)]] (2/2) (duration: 01m 05s)

Change 720972 merged by jenkins-bot:

[mediawiki/extensions/WikimediaBadges@master] Add strict types

https://gerrit.wikimedia.org/r/720972

Change 720973 merged by jenkins-bot:

[mediawiki/extensions/WikimediaBadges@master] Update logic for Wikimedia Commons sitelink

https://gerrit.wikimedia.org/r/720973

Great that this is moving forward. :-) Do you want me to help test it on the beta cluster? If so, I'd need some pointers - in particular, how to set up links between Wikidata beta and Commons beta, and then test them on enwiki beta (assuming all three exist!). Or more generally, how the beta cluster works relative to the main wikis, since I've not used them before!