Page MenuHomePhabricator

SpecialNewLexeme: using const for name causes fatal error
Closed, ResolvedPublic

Description

Exception: ('command: ', "echo 'aawiki'; /usr/local/bin/mwscript update.php --wiki=aawiki --quick", 'output: ', 'aawiki\n#!/usr/bin/env php\n[Mon Sep  3 11:20:02 2018] [hphp] [7080:7fcd4c49f3c0:0:000001] [] \nFatal error: unknown class Wikibase\\Repo\\Specials\\SpecialNewEntity in /srv/mediawiki-staging/php-master/extensions/WikibaseLexeme/src/Specials/SpecialNewLexeme.php on line 32

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 3 2018, 11:45 AM

Change 457421 had a related patch set uploaded (by Pablo Grass (WMDE); owner: Pablo Grass (WMDE)):
[mediawiki/extensions/WikibaseLexeme@master] Revert "SpecialNewLexeme: use const for name"

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

Quoting @Lucas_Werkmeister_WMDE

Using SpecialNewLexeme::PAGE_NAME requires the class to be loaded unconditionally, which in turn requires its superclass, SpecialNewEntity, to be available. However, that class is not available on wikis where WikibaseRepo is not enabled, resulting in an error.

Jakob_WMDE removed a subscriber: Jakob_WMDE.
Jakob_WMDE added a subscriber: Jakob_WMDE.

Change 457421 merged by jenkins-bot:
[mediawiki/extensions/WikibaseLexeme@master] Revert "SpecialNewLexeme: use const for name"

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

Pablo-WMDE closed this task as Resolved.Sep 3 2018, 12:29 PM

This incident is now resolved.

/cc @Reedy

Pablo-WMDE removed Pablo-WMDE as the assignee of this task.Sep 3 2018, 12:30 PM

I'll paste part of my brain dump (slightly modified) from an email into this ticket for searchability:


So I think the thing that actually caused the issue to show up is the difference between class loading in Wikibase and WikibaseLexeme.

Currently Wikibase only loads the classes for the given extension, so if you load WikibaseClient only you will not get the WikibaseRepo classes.
The behaviour in Lexeme is different as it uses the extension registration system to load the classes.
So if you are only loading the Client side of WikibaseLexeme, you will actually load ALL classes even if you don't use them all :/

The 'best solution' for this would probably be to have 2 separate extension.json entry points for the lexeme extension, one for client stuff, one for repo stuff.
Right now we have 1 entry point, and then a bunch of conditional stuff in Wikibase\\Lexeme\\Registrar::registerExtension that handles the client / repo split.
In order to correctly load client vs repo classes in Lexeme we would also have to fix the namespacing I guess, as right now there is no actual divide in the code.

There are 2 jobs in the Wikibase CI that in theory run with half of the main extension loaded (ie either repo or client).
These can be seen with the following examples:

They do the following for example:

04:14:05 + echo '$wgEnableWikibaseRepo = false;'
04:14:05 + echo '$wgEnableWikibaseClient = true;'
04:14:05 + echo '$wgWikimediaJenkinsCI = true;'
04:14:05 + echo '$wmgUseWikibaseRepo = false;'
04:14:05 + echo '$wmgUseWikibaseClient = true;'
04:14:05 + echo 'require_once __DIR__ . "/extensions/Wikibase/Wikibase.php";'

I kind of feel like this should have caught the issue (not in the Lexeme CI though)

There has been some relevant discussion on T188717 recently about the split between repo and client, and also the possible use of extension registration for Wikibase.