Page MenuHomePhabricator

Remove WB_VERSION, WBL_VERSION, WBC_VERSION constants
Closed, ResolvedPublic

Description

The “version” has been frozen at “0.5 alpha” for years and years, and nowadays the constants are only used to detect whether the extensions are loaded or not. Do that via ExtensionRegistry instead. (The constants are inconvenient because we can’t set them in the extension JSON file.)

Related Objects

View Standalone Graph
This task is connected to more than 200 other tasks. Only direct parents and subtasks are shown here. Use View Standalone Graph to show more of the graph.

Event Timeline

Change 607521 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikimediaEvents@master] Stop using WB_VERSION

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

Change 607522 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/ArticlePlaceholder@master] Stop using WB_VERSION

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

Change 607526 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/ContentTranslation@master] Stop using WBC_VERSION

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

Change 607527 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/VisualEditor@master] Stop using WBC_VERSION

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

Change 607526 merged by jenkins-bot:
[mediawiki/extensions/ContentTranslation@master] Stop using WBC_VERSION

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

Change 607527 merged by jenkins-bot:
[mediawiki/extensions/VisualEditor@master] Stop using WBC_VERSION

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

Change 607545 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseLexeme@master] Stop using WB_VERSION

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

Change 607522 merged by jenkins-bot:
[mediawiki/extensions/ArticlePlaceholder@master] Stop using WB_VERSION

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

Change 607521 merged by jenkins-bot:
[mediawiki/extensions/WikimediaEvents@master] Stop using WB_VERSION

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

Change 607545 merged by jenkins-bot:
[mediawiki/extensions/WikibaseLexeme@master] Stop using WB_VERSION

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

This snippet in WikibaseClient.example.php is going to be interesting:

// If this wiki also runs the Wikibase repo extension,
// use the automatic defaults for repo-related settings.
// If this wiki isn't running the repo extension,
// configure an example repo.
if ( !defined( 'WB_VERSION' ) ) {

I stepped through it with the debugger to confirm my suspicion – at the point that this file is loaded, the WikibaseRepository extension is not yet loaded (i. e. ExtensionRegistry::getInstance()->isLoaded( 'WikibaseRepository' ) will return false). The extension is queued, which we could detect by finding its JSON file in ExtensionRegistry::getInstance()->getQueue(), but that method is internal and “not intended to be used outside of the installer”. This also touches on task T256252: Migrate wgWBClientDataTypes + wgWBClientSettings loading out of Client PHP entry point, I think.

Change 607785 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Stop checking WB[LC]?_VERSION for registration

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

Change 607792 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Remove WBL_VERSION from cache key prefix

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

Change 607792 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Remove WBL_VERSION from cache key prefix

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

Change 607785 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Stop checking WB[LC]?_VERSION for registration

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

Remaining uses of the constants:

  • To check whether Repo or Client are enabled, in WikibaseSettings. Can be removed once I15020f34b2 has rolled out with the train and we haven’t seen any “used during early initialization” warnings in logstash. (When doing that, also change the comments in WikibaseClient.default.php and ClientDefaultsTest.php, for the thisWikiIsTheRepo setting, to mention ExtensionRegistry rather than WB_VERSION.)
  • To check whether the main PHP entry point was loaded correctly, in Wikibase.example.php and WikibaseClient.example.php – they die() with a message to load the PHP entry point first if the constant isn’t defined. I think this can be replaced with a more general check for the MEDIAWIKI constant (the standard “not an entry point” error pattern in PHP entry points, back before extension.json was a thing): I don’t think it’s necessary to check the Wikibase-specific constants. (Historical note: the first check of a Wikibase-specific constant, rather than the general MEDIAWIKI constant, was added in Iee722e1425, November 2012. Prior to that change, Wikibase.experimental.php had been an alternative entry point that could be used instead of Wikibase.php; with that change, Wikibase.php was the only entry point, and experimental features were enabled with define( 'WB_EXPERIMENTAL_FEATURES', true ) instead. (The whole concept of experimental features was then later dropped in favor of more specific feature flags, in I5fd3c44cc4, October 2015.) So at that point, it actually made sense to check the Wikibase-specific constant and tell users to use the correct PHP entry point instead, because previously they had been told to use Wikibase.experimental.php as the entry point and now they needed to update their LocalSettings.php. Shortly afterwards, in I8313756e94, February 2013, more PHP entry points were added, and they also checked Wikibase-specific constants – here, I assume, this was more or less copy+pasted from the Wikibase.experimental.php check, but I don’t think it was really necessary, since the files in question were completely new, and there was no reason to expect anybody to load them directly without first loading the correct entry points. And now, over seven years later, I think the risk of anybody directly loading the wrong entry point, and therefore needing the detailed error message “you should load this other entry point instead”, is nil.)
  • To check whether an example repository should be configured, in WikibaseClient.example.php. If the current wiki is also a repo, then WikibaseClient uses it by default and needs to special configuration, but if the current wiki is not a repo, then those example settings will configure an example repo (database repo, URL http://repo.example.org, etc.). At some point during the extension registration work, we’ll have to think about the whole settings business anyways; but for now, just to resolve this task and get rid of the WB[CL]?_VERSION constants, I propose to introduce a new constant just for this one use case, which will not be used anywhere else, especially not in other extensions – something like WB_NO_CONFIGURE_EXAMPLE_REPO, defined in the Repo PHP entry point and checked in WikibaseClient.example.php.

Change 608323 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Don’t check WBC?_VERSION constants in example config

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/ /608323

Change 608326 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Remove WBL_VERSION constant

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/ /608326

Change 608323 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Don’t check WBC?_VERSION constants in example config

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/ /608323

Change 608326 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Remove WBL_VERSION constant

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/ /608326

Change 609137 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Stop checking WBC?_VERSION for extension registration

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/ /609137

Change 609138 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Remove WBC_VERSION constant

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/ /609138

Change 609166 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Don’t use WB_VERSION in Client example config

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/ /609166

Change 609166 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Don’t use WB_VERSION in Client example config

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/ /609166

Change 609137 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Stop checking WBC?_VERSION for extension registration

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/ /609137

Change 609138 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Remove WBC_VERSION constant

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/ /609138

Change 609205 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Remove WB_VERSION constant

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/ /609205

Change 609205 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Remove WB_VERSION constant

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

Change 609791 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/vagrant@master] Stop using WBL_VERSION constant

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

Change 609791 merged by jenkins-bot:
[mediawiki/vagrant@master] Stop using WBL_VERSION constant

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