Page MenuHomePhabricator

Wikilambda: Change the definition of references so that it only includes internal Wikifunctions references (Zids)
Closed, ResolvedPublic

Description

Description

We have agreed to change the definition of references throughout the system:
References will not include Wikidata identifiers, such as those for lexemes (e.g. L12345), lexeme forms, items, and properties.
The same arguments apply to all potential external identifiers, so that the new definition should only include identifiers starting with Z.

Wikilambda ZObjectUtils contains the following pattern matching validation function:

/**
 * Is the input a valid possible identifier across WMF projects?
 *
 * @param string $input
 * @return bool
 */
public static function isValidId( string $input ): bool {
  return preg_match( "/^[A-Z][1-9]\d*$/", $input );
}

ZObjectUtils also contains:

  • isValidZObjectReference: matching identifiers that start with the character Z, and
  • isValidZObjectKey: matching identifiers that start with the character K.

ZObjectUtils:isValidId is used in some places, we should:

  • Check why is this function being used, and
  • Replace it with the correct one (most likely isValidZObjectReference)

Completion checklist

Event Timeline

gengh created this task.

Change #1070248 had a related patch set uploaded (by Genoveva Galarza; author: Genoveva Galarza):

[mediawiki/extensions/WikiLambda@master] Use isValidZObjectReference instead of isValidId

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

Does this fix T343593? Or does T373852?

Not intentionally; this is about an interim set of changes to references so we can land some of the Wikidata fetching/using code without re-building the entire concept of how references are used throughout the codebases. In the future, these changes will probably be undone (with a lot more work instead).

Change #1070248 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Use isValidZObjectReference instead of isValidId

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

Does this fix T343593? Or does T373852?

Not intentionally
[…]

Thanks, I’ll check when it goes live 🤞

Does this fix T343593? Or does T373852?

Not intentionally…[snip]

It looks like this fixed the general problem exemplified by Z10012 but not the specific issue raised in the original Bug Report (T343593).