Page MenuHomePhabricator

Create a code abstraction for "display entity link" use-case
Closed, ResolvedPublic

Description

Create a set of classes/interfaces that will be used for display purposes only.
Cache would be used instead of using the secondary wb_terms SQL table.

Input: EntityId
Output: Data that is enough to display HTML/wikitext link to the Entity page (probably including things like label, description, if language fallback was used)

This task focuses on items, and properties.
Similar approach would be likely also used for Lexeme and MediaInfo entities - this is left out for the follow up work.

Event Timeline

Change 439885 had a related patch set uploaded (by Aleksey Bekh-Ivanov (WMDE); owner: Aleksey Bekh-Ivanov (WMDE)):
[mediawiki/extensions/Wikibase@master] Separate HTML link formatter for ItemIds

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

Change 439927 had a related patch set uploaded (by Aleksey Bekh-Ivanov (WMDE); owner: Aleksey Bekh-Ivanov (WMDE)):
[mediawiki/extensions/Wikibase@master] Refactor ItemIdHtmlLinkFormatterTest

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

Change 439885 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Separate HTML link formatter for ItemIds

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

Change 439927 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Refactor ItemIdHtmlLinkFormatterTest

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

Change 441019 had a related patch set uploaded (by Aleksey Bekh-Ivanov (WMDE); owner: Aleksey Bekh-Ivanov (WMDE)):
[mediawiki/extensions/Wikibase@master] Add ControlledFallbackEntityIdFormatter to be able to replace formatter gracefully

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

Change 441019 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Add ControlledFallbackEntityIdFormatter to be able to replace formatter gracefully

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

Change 442260 had a related patch set uploaded (by WMDE-leszek; owner: WMDE-leszek):
[mediawiki/extensions/Wikibase@master] Added CachingFallbackLabelDescriptionLookup

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

Change 442861 had a related patch set uploaded (by WMDE-leszek; owner: WMDE-leszek):
[mediawiki/extensions/Wikibase@master] WIP DRAFT Document decision about not using wb_terms for "display" of items/properties

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

Change 442879 had a related patch set uploaded (by WMDE-leszek; owner: WMDE-leszek):
[mediawiki/extensions/Wikibase@master] WIP DRAFT ADR document about using PSR-16 Cache interface

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

Change 442879 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] ADR document about using PSR-16 Cache interface

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

Change 442260 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Added CachingFallbackLabelDescriptionLookup

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

Change 452931 had a related patch set uploaded (by Aleksey Bekh-Ivanov (WMDE); owner: Aleksey Bekh-Ivanov (WMDE)):
[mediawiki/extensions/Wikibase@master] Add internal assertions to ensure the code works correctly

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

Found the problem with current solution.

lib/includes/Store/Sql/WikiPageEntityRevisionLookup.php:142

if ( $row && $row->page_latest && !$row->page_is_redirect ) {
	return (int)$row->page_latest;
}

return false;

That means that we don't get correct revision ID if the target entity is redirect.
That leads to invalid cache record (or Exception being thrown if the patch 452931 is merged) and essentially means that the code is not production ready.

It still can be deployed as soon as this code is disabled using configuration value.

Change 454857 had a related patch set uploaded (by Aleksey Bekh-Ivanov (WMDE); owner: Aleksey Bekh-Ivanov (WMDE)):
[mediawiki/extensions/Wikibase@master] Handle redirects in CachingFallbackLabelDescriptionLookup

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

Change 452931 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Add internal assertions to ensure the code works correctly

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

Change 454857 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Handle redirects in CachingFallbackLabelDescriptionLookup

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

Change 456401 had a related patch set uploaded (by Aleksey Bekh-Ivanov (WMDE); owner: Aleksey Bekh-Ivanov (WMDE)):
[mediawiki/extensions/Wikibase@master] Return redirect result from WikiPageEntityRevisionLookup::getLatestRevisionId

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

Change 456401 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Return redirect result from WikiPageEntityRevisionLookup::getLatestRevisionId

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

Except T205192 there is also the issue that EntityInfoBuilder is also involved when generating the links on the item etc page, and it is still hitting wb_terms. That is T198868, or T205193 in particular.
Arguably, changing this is not blocking this is not required to consider this use case solved, but it would be really nasty to leave not changed.

Addshore claimed this task.

Done, ControlledFallbackEntityIdFormatter

Change 442861 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Document decision about not using wb_terms for "display" of items/properties

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

Change 593460 had a related patch set uploaded (by Addshore; owner: Addshore):
[mediawiki/extensions/Wikibase@master] docs: WikiPageEntityRevisionLookup::getLatestRevisionId and redirects

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

Change 593460 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] docs: WikiPageEntityRevisionLookup::getLatestRevisionId and redirects

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