Page MenuHomePhabricator

[ES-M2]: "What Links Here" on EntitySchemas
Closed, ResolvedPublic13 Estimated Story Points

Description

As a Wikidata editor, I want to see what Items, Lexemes and Properties have statements that link to an EntitySchema in order to model better data.

Problem:
EntitySchema's "What Links Here" currently show all pages that refer to an EnititySchemas in Wikitext etc.

But as we do not currently have a EntitySchema datatype users are unable to reference them in statements.

Once a new EntitySchema datatype has been created T214884, users will be able to indicate what class of Items, Lexemes and Properties are governed by an EntitySchema by linking to them through statements.

We would then like to enable users to easily see what Items, Lexemes and Properties are governed by an EntitySchema by displaying all entities that refer to it in statements in "What Links Here"

BDD
GIVEN EntitySchema datatype
AND EntitySchema "What Links Here"
WHEN a statement is added to an Item or Lexeme or Property using the EntitySchema datatype
THEN the EntitySchema's "What Links Here" shows the Item or Lexeme or Property that has the statement

Acceptance criteria:

  • "What Links Here" on an EntitySchema should list all entities (Items, Lexemes etc.) linking to it through the new datatype

Open questions:

Event Timeline

Arian_Bozorg renamed this task from ES - M2: "What Links Here" on EntitySchemas to [ES-M1]: "What Links Here" on EntitySchemas.Mar 9 2023, 2:48 PM
Arian_Bozorg renamed this task from [ES-M1]: "What Links Here" on EntitySchemas to [ES-M2]: "What Links Here" on EntitySchemas.Mar 9 2023, 3:23 PM

Wikibase assembles the outgoing links from an entity page via the EntityReferenceExtractor, called by the ReferencedEntitiesDataUpdater. Since we’re using the string data value type instead of the entity ID data value type, I think we need to add a hook to StatementEntityReferenceExtractor::processSnak() or somewhere in the vicinity. (processDataValue() in its current form isn’t enough: by that point, we don’t know which property data type the data value belonged to, i.e. whether a StringValue('E10') is an EntitySchema reference or some unrelated string.)

Mh, there is \Wikibase\Repo\ParserOutput\EntityParserOutputDataUpdaterCollection, which looks like we could in principle add an EntitySchemaParserOutputDataUpdater to it.

Though going a bit up the call stack, it seems Wikibase has custom code for associated extensions to add their updaters in \Wikibase\Repo\ParserOutput\EntityParserOutputGeneratorFactory::getDataUpdaters

EntityParserOutputGeneratorFactory::getDataUpdaters
	private function getDataUpdaters(): array {

		// [...]

		if ( ExtensionRegistry::getInstance()->isLoaded( 'GeoData' ) ) {
			$statementUpdater->addUpdater( $this->newGeoDataDataUpdater( $propertyDataTypeMatcher ) );
		}

		if ( ExtensionRegistry::getInstance()->isLoaded( 'Math' ) ) {
			$statementUpdater->addUpdater( new MathDataUpdater( $propertyDataTypeMatcher ) );

		}

		// FIXME: null implementation of KartographerEmbeddingHandler would seem better than null pointer
		// in general, and would also remove the need for the check here
		if ( $this->kartographerEmbeddingHandler ) {
			$statementUpdater->addUpdater( $this->newKartographerDataUpdater() );
		}

		// [...]

		// TODO: do not use global state
		Hooks::run(
			'WikibaseRepoOnParserOutputUpdaterConstruction',
			[
				$statementUpdater,
				&$entityUpdaters,
			]
		);

		return $entityUpdaters;
	}

And there is also a hook that looks like we could use it? Though in general this method has a lot of // TODO and // FIXME to it, that maybe we want to use this opportunity to spend a bit of time on thinking about how we can improve it.

That WikibaseRepoOnParserOutputUpdaterConstruction hook is apparently what Lexeme is using (see codesearch to add LexemeParserOutputUpdater to the stack.

Change 909691 had a related patch set uploaded (by Hoo man; author: Hoo man):

[mediawiki/extensions/EntitySchema@master] Add statement links to EntitySchema "What links here"

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

Change 909691 merged by jenkins-bot:

[mediawiki/extensions/EntitySchema@master] Add statement links to EntitySchema "What links here"

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

Amazing! Thanks so much everyone :)