daniel added a comment.

The issue here is how SummaryFormatter and LinkBeginHookHandler interact:

  • SummaryFormatter uses a EntityIdPlainLinkFormatter to generate wiki-links for each entity.
  • LinkBeginHookHandler recognized links to entity pages, and automatically looks up the entity's label and uses it as the link text.

For foreign entities however, EntityIdPLainLinkFormatter would generate a link of the form [[foo:Special:EntityPage/P17]], which LinkBeginHookHandler does not recognize, since it's not a link to a local entity namespace.

After some discussion with @WMDE-leszek, I see two options to address this:

  1. teach LinkBeginHookHandler to parse links of the form [[foo:Special:EntityPage/P17]]. The pattern is easy enough, we can check whether foo is a known repo, and we can construct the EntityId foo:P17 unambiguously (using for now the assumption that repo names and interwiki prefixes are the same).
  2. make EntityIdPlainLinkFormatter (or a simmilar class) emit links of the form [[foo:Special:EntityPage/P17|foo:P17]], using the serialized ID as the link text (at least if it's different from the link target). This would give LinkBeginHookHandler more information to work with, but it also breaks some assumptions, and requires some refactoring. In particular:
  • LinkBeginHookHandler would need to be migrated from the deprecated LinkBegin hook to the new HtmlPageLinkRendererBegin hook. Care must be taken to correctly convert from the old $html to the new $text parameter.
  • The handler function should look at $text, and if it is a string and can be parsed as an EntityId, it looks up the label and replaced $text accordingly (with an HtmlArmor object). If EntityId is null or empty, the old code for parsing the link target should be used. This needs to be supported indefinitely, so we can still render old edit summaries correctly.
  • This breaks the assumption that the LinkBeginHookHandler magic that localized entity links will only kick in if no link text was explicitly given. There might be some code that explicitly sets the link text to the ID, in the expectation that it will not be replaced by the label.

TASK DETAIL
https://phabricator.wikimedia.org/T157004

EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: daniel
Cc: daniel, Aklapper, Lydia_Pintscher, WMDE-leszek, D3r1ck01, Izno, Wikidata-bugs, aude, Mbch331
_______________________________________________
Wikidata-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs

Reply via email to