Page MenuHomePhabricator

Wikibase on Vagrant: Class 'Wikibase\DataModel\Entity\ItemId' not found
Closed, ResolvedPublic

Description

Running vagrant git-update with the wikibase role enabled gives me this:

[d6082a1b37919ea1f563e7a7] [no req]   Error from line 35 of /vagrant/mediawiki/extensions/Wikibase/lib/WikibaseLib.entitytypes.php: Class 'Wikibase\DataModel\Entity\ItemId' not found
Backtrace:
#0 /vagrant/mediawiki/extensions/Wikibase/repo/includes/WikibaseRepo.php(566): require()
#1 /vagrant/mediawiki/extensions/Wikibase/repo/includes/WikibaseRepo.php(312): Wikibase\Repo\WikibaseRepo::getDefaultEntityTypes()
#2 /vagrant/mediawiki/extensions/Wikibase/repo/includes/WikibaseRepo.php(370): Wikibase\Repo\WikibaseRepo::newInstance()
#3 /vagrant/mediawiki/extensions/Wikibase/repo/RepoHooks.php(100): Wikibase\Repo\WikibaseRepo::getDefaultInstance()
#4 /vagrant/mediawiki/includes/Hooks.php(174): Wikibase\RepoHooks::onSetupAfterCache()
#5 /vagrant/mediawiki/includes/Hooks.php(202): Hooks::callHook(string, array, array, NULL)
#6 /vagrant/mediawiki/includes/Setup.php(791): Hooks::run(string)
#7 /vagrant/mediawiki/maintenance/doMaintenance.php(81): require_once(string)
#8 /vagrant/mediawiki/maintenance/update.php(245): require_once(string)
#9 /var/www/w/MWScript.php(98): require_once(string)
#10 {main}

The missing class gets installed by Composer, and is included in the autoloader classmap generated by Composer, so presumably that classmap does not get loaded. See the load_composer_autoloader property in extension.json for how that's normally done.

Caused by rEWBA505e4860cc72: Remove optional dependency on Wikibase local vendor directory.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

this is likely related to recent change in Wikibase. using compser merge plugin and composer.local.json would be a way to go now.
Will try to follow up on this bug soon (it's end of work day for me now).

I tried to figure out what could have happened wrong here, but I am actually not sure. both wikibase_repo and wikidata roles include

mediawiki::extension { 'Wikibase':
    composer     => true,
    needs_update => true,
  }

Unless I understand it wrong, "composer => true" adds appropriate entry to composer.local.json, so then composer update/install should install Wikibase Data Model library.

@Tgr could you maybe paste some more error output here, if vagrant says anything more than what you've quoted above?

Vagrant throws this every time it tries to do something with MediaWiki (that is, run some maintenance script) so the full log is not super useful.

As I said, this is caused by extensions/Wikibase/vendor/autoload.php not being loaded. The way Vagrant is set up (and many third-party sites too), extensions have separate Composer installations from core so extension files are not included in vendor/autoload.php. Normally ExtensionProcessor::getExtraAutoloaderPaths() handles that but Wikibase does not use extension registration so needs to do it by hand. Here's a random example of an extension doing that in the pre-extension-registration times.

Yes, I think I have the same issue. It looks like non-extension.json extensions under Vagrant are expected to load their own vendor/autoload.php (e.g. CirrusSearch does) and Wikibase does not do it now.

Adding "extensions/Wikibase/composer.json" to include list in composer.local.json seems to fix the issue, but this does not seem right - it probably should go to settings.d/composer but I am not sure how to properly do that.

Apologies for late response. If it is possible to fairly easy adjust mw vagrant and wikibase role, so that composer.local.json is utilized, that would be a preferred way from my perspective. That said, I have to admit that WMDE we've move away from vagrant, and would take us a bit more time that one would expect from quick fixing. So in case you guys don't find a neat way to do the trick on vagrant level, or don't have time to do this, I guess I would temporarily restore manual loading of composer generated autoload files.

Converting Wikibase to use extension.json would be a more plausible "proper" fix, but this is sadly a more of a project, and I wouldn't like to leave vagrant role broken for that much time.

Handling this in Vagrant is not hard, but Vagrant is not the only one using separate composer install commands per extension; some wikifarms do that due to composer being unwieldy with lots of dependencies. So it would be better if Wikibase supported that pattern, or alternatively there should be an agreement (RfC?) that that's not something to be supported and support should be removed from Vagrant (again, not hard, we could just change php::composer::install to work like mediawiki::composer::require does).

I think if we want to support this pattern (working only via parent composer) there should be some class or option in Vagrant that does it. But if enabling local composer on Wikibase is not too much trouble, I think this should be an option too, at least for now.

I also just hit this issue and it broke our staging environment. I've applied the local json fix for the time being from @Smalyshev to restore it.

At WMDE we're realistically going to work on making Wikibase use extension.json earliest in September. This should fix the vagrant role, and other issues that have been pointed out above.

As there is a workaround in place, and the impact of this issue does not seem too severe from our perspective, we've decided to not re-add 'include vendor/autoload.php' lines to Wikibase code. We'd rather solve the issue properly, and not "buy" ourselves more time for pushing adding extension.json to Wikibase even further by having temporary-turned-permanent hacks in our code.

Change 463585 had a related patch set uploaded (by Smalyshev; owner: Smalyshev):
[mediawiki/vagrant@master] Add composer include file for Wikibase

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

Change 463585 merged by jenkins-bot:
[mediawiki/vagrant@master] Add composer include file for Wikibase

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

I'm getting this error again with a completely fresh install.

I'm not sure if it's the same or similar issue:

T208500

Seems to have regressed at some point.