Page MenuHomePhabricator

`Class 'Wikibase\DataModel\Entity\ItemId' not found` error when trying to install WikibaseLexeme
Closed, ResolvedPublic

Description

I am trying to set up development environment for WikibaseLexeme.

I am following instructions at addshore/mediawiki-docker-dev and wikimedia/mediawiki-extensions-WikibaseLexeme.

Everything works fine until I run this from WikibaseLexeme/README.md:81:

1~/Documents/github/addshore/mediawiki-docker-dev$ docker-compose exec "web" php /var/www/mediawiki/maintenance/update.php --wiki default --quick
2[26142080ebaf7fde12c6233c] [no req] Error from line 35 of /var/www/mediawiki/extensions/Wikibase/lib/WikibaseLib.entitytypes.php: Class 'Wikibase\DataModel\Entity\ItemId' not found
3Backtrace:
4#0 /var/www/mediawiki/extensions/Wikibase/repo/includes/WikibaseRepo.php(567): require()
5#1 /var/www/mediawiki/extensions/Wikibase/repo/includes/WikibaseRepo.php(313): Wikibase\Repo\WikibaseRepo::getDefaultEntityTypes()
6#2 /var/www/mediawiki/extensions/Wikibase/repo/includes/WikibaseRepo.php(371): Wikibase\Repo\WikibaseRepo::newInstance()
7#3 /var/www/mediawiki/extensions/Wikibase/repo/RepoHooks.php(98): Wikibase\Repo\WikibaseRepo::getDefaultInstance()
8#4 /var/www/mediawiki/includes/Hooks.php(174): Wikibase\RepoHooks::onSetupAfterCache()
9#5 /var/www/mediawiki/includes/Hooks.php(202): Hooks::callHook(string, array, array, NULL)
10#6 /var/www/mediawiki/includes/Setup.php(791): Hooks::run(string)
11#7 /var/www/mediawiki/maintenance/doMaintenance.php(81): require_once(string)
12#8 /var/www/mediawiki/maintenance/update.php(245): require_once(string)
13#9 {main}

Event Timeline

Restricted Application added a subscriber: Aklapper. ยท View Herald Transcript

@Addshore can you help? Do you need more information?

Just looking at the error message it would seem composer didn't pull in dependencies. But looking at README.md running composer is mentioned to be done before running update.php (which makes sense), so I don't quite get why it could fail.

Maybe @Tarrow has an idea what could be going wrong here?

I don't have much experience with Docker, so in attempt to start clean, I have deleted addshore/mediawiki-docker-dev, mediawiki/core, Wikibase and WikibaseLexeme repositories and cloned them again. I get the same error message. I think I remember the instructions working fine before on this machine and at another machine. I am not sure what changed in the meantime.

How do I make sure that I have removed all Docker stuff and start fresh? That might be easier than trying to debug what went wrong?

I am not a docker ninja, but when in a need to remove ALL docker stuff I use: docker system prune.
Note that it is going to remove all stopped containers, not only mediawiki ones (if you have others running).
Also keep in mind the note about volumes from the docs (i.e. if you want to remove all all then also run: docker system prune --volumes)

Thanks, I did run docker system prune and docker system prune --volumes. I still get the same error message. ๐Ÿ˜ข

Have you run composer update / install on both mediawiki and Wikibase and WikibaseLexeme?
Or are you using the composer merge-plugin to install all extension deps under the core vendor dir?
Or are you using the mediawiki-vendor git repo?

I am following instructions from addshore/mediawiki-docker-dev and wikimedia/mediawiki-extensions-WikibaseLexeme. I am at docker-compose exec "web" php /var/www/mediawiki/maintenance/update.php --wiki default --quick step of WikibaseLexeme's readme file. I can provide the entire terminal output if that would help.

@zeljkofilipin Can you paste a copy of the composer.lock file in your root mediawiki dir?

Okay, so https://packagist.org/packages/wikibase/data-model isn't listed there at all.
It doesn't look like you have done the "Install the dependencies with composer:" step in the WikibaseLexeme readme.

What is in your composer.local.json in the root mediawiki dir?

It doesn't look like you have done the "Install the dependencies with composer:" step in the WikibaseLexeme readme.

But I did:

~/Documents/gerrit/mediawiki/core$ docker run -it --rm --user $(id -u):$(id -g) -v ~/.composer:/composer -v $(pwd):/app docker.io/composer install
> ComposerHookHandler::onPreInstall
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating optimized autoload files
> ComposerVendorHtaccessCreator::onEvent

What is in your composer.local.json in the root mediawiki dir?

{
	"extra": {
		"merge-plugin": {
			"include": [
				"extensions/Wikibase/composer.json"
			]
		}
	}
}

Hmmmm

Nothing to install or update

but wikibase/data-model still isn't in your composer.lock?

Could be some sort of bug with the composer merge plugin?

All I can think of suggestion is remove you vendor dir and the composer.lock file and try again.

but wikibase/data-model still isn't in your composer.lock?

No.

Could be some sort of bug with the composer merge plugin?

๐Ÿคทโ€โ™‚๏ธ

All I can think of suggestion is remove you vendor dir and the composer.lock file and try again.

Deleted vendor, composer.lock and composer.local.json.

~/Documents/gerrit/mediawiki/core$ docker run -it --rm --user $(id -u):$(id -g) -v ~/.composer:/composer -v $(pwd):/app docker.io/composer install
> ComposerHookHandler::onPreUpdate
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 82 installs, 0 updates, 0 removals
  - Installing wikimedia/composer-merge-plugin (v1.4.1): Downloading (100%)  
...
Writing lock file
Generating optimized autoload files
> ComposerHookHandler::onPreUpdate
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
Generating optimized autoload files
> ComposerVendorHtaccessCreator::onEvent
> ComposerVendorHtaccessCreator::onEvent

Created composer.local.json.

~/Documents/gerrit/mediawiki/core$ docker run -it --rm --user $(id -u):$(id -g) -v ~/.composer:/composer -v $(pwd):/app docker.io/composer install
> ComposerHookHandler::onPreInstall
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 0 installs, 1 update, 0 removals
  - Updating jetbrains/phpstorm-stubs dev-master (1b99060 => 75aeabe):  Checking out 75aeabe30f
Generating optimized autoload files
> ComposerVendorHtaccessCreator::onEvent

It did not install anything, just one update. ๐Ÿค”

Change 442283 had a related patch set uploaded (by Zfilipin; owner: Zfilipin):
[mediawiki/extensions/WikibaseLexeme@master] Add missing curly bracket to readme file

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

Change 442283 merged by jenkins-bot:
[mediawiki/extensions/WikibaseLexeme@master] Add missing curly bracket to readme file

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

Does it work with the fix in the README from the patch?

My composer.local.json was always good, I have noticed that the readme was wrong in a desperate attempt to follow the instructions blindly. ๐Ÿ•ถ

So, nobody else can reproduce the problem?

Maybe there is something wrong with my machine. Do I need to have a specific version of composer or composer merge plugin?

How do I make sure I have removed everything and start from scratch? I have tried deleting addshore/mediawiki-docker-dev, core, extensions and skins. I have run docker system prune, docker system prune --volumes and docker system prune --all.

@Tarrow as you wrote the readme and I assume use the composer merge plugin any chance you could take a look at this?

I will certainly take a look but I don't actually use the composer merge plugin.

I altered the instructions to use it after hearing from someone in the office that they've had a big discussion about it and it's the "right" way to do it. Perhaps it's actually clunkier..

Change 443044 had a related patch set uploaded (by Tarrow; owner: Tarrow):
[mediawiki/extensions/WikibaseLexeme@master] Include more details about composer running in README.md

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

I'm happy to report I can repeat the problem; I guess the issue is something about the merge plugin not running until the first run after it is installed.

The solution seems to be to run composer install twice.

I'll add this to the readme.

CommunityTechBot renamed this task from ziaaaaaaaa to `Class 'Wikibase\DataModel\Entity\ItemId' not found` error when trying to install WikibaseLexeme.Jul 2 2018, 11:24 AM
CommunityTechBot updated the task description. (Show Details)
CommunityTechBot added subscribers: gerritbot, Aklapper.

Change 443044 merged by jenkins-bot:
[mediawiki/extensions/WikibaseLexeme@master] Include more details about composer running in README.md

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

zeljkofilipin claimed this task.

I had the same error message Error from line 35 of /var/www/mediawiki/extensions/Wikibase/lib/WikibaseLib.entitytypes.php: Class 'Wikibase\DataModel\Entity\ItemId' not found when trying to run the update.php script after an upgrade of my wiki from 1.34 to 1.35. Turns out it wasn't so much a composer problem, as it was that I simply hadn't run

git submodule update --init --recursive

in the extensions/Wikibase directory. I had git cloned Wikibase from branch REL1_35, but then you need to run git submodule update in the Wikibase extension folder and then after that run composer update --no-dev.

@hyperreview did you try this?

I had the same error message Error from line 35 of /var/www/mediawiki/extensions/Wikibase/lib/WikibaseLib.entitytypes.php: Class 'Wikibase\DataModel\Entity\ItemId' not found when trying to run the update.php script after an upgrade of my wiki from 1.34 to 1.35. Turns out it wasn't so much a composer problem, as it was that I simply hadn't run

git submodule update --init --recursive

in the extensions/Wikibase directory. I had git cloned Wikibase from branch REL1_35, but then you need to run git submodule update in the Wikibase extension folder and then after that run composer update --no-dev.

@hyperreview did you try this?

I had the same error message Error from line 35 of /var/www/mediawiki/extensions/Wikibase/lib/WikibaseLib.entitytypes.php: Class 'Wikibase\DataModel\Entity\ItemId' not found when trying to run the update.php script after an upgrade of my wiki from 1.34 to 1.35. Turns out it wasn't so much a composer problem, as it was that I simply hadn't run

git submodule update --init --recursive

in the extensions/Wikibase directory. I had git cloned Wikibase from branch REL1_35, but then you need to run git submodule update in the Wikibase extension folder and then after that run composer update --no-dev.

Yes, I've also tried again from scratch but I'm getting new errors:

MediaWiki internal error.

Original exception: [00ef68d55f0f209ff2491da7] /wiki/Speciale:Versione TypeError: Argument 1 passed to Wikibase\Client\Hooks\ExtensionLoadHandler::getApiFormatReferenceSpec() must be of the type array, null given, called in /home/251650.cloudwaysapps.com/wyvytmmgmu/public_html/extensions/Wikibase/client/includes/Hooks/ExtensionLoadHandler.php on line 47
Backtrace:
from /home/251650.cloudwaysapps.com/wyvytmmgmu/public_html/extensions/Wikibase/client/includes/Hooks/ExtensionLoadHandler.php(74)
#0 /home/251650.cloudwaysapps.com/wyvytmmgmu/public_html/extensions/Wikibase/client/includes/Hooks/ExtensionLoadHandler.php(47): Wikibase\Client\Hooks\ExtensionLoadHandler->getApiFormatReferenceSpec()
#1 /home/251650.cloudwaysapps.com/wyvytmmgmu/public_html/includes/Setup.php(838): Wikibase\Client\Hooks\ExtensionLoadHandler::onExtensionLoad()
#2 /home/251650.cloudwaysapps.com/wyvytmmgmu/public_html/includes/WebStart.php(87): require_once(string)
#3 /home/251650.cloudwaysapps.com/wyvytmmgmu/public_html/index.php(44): require(string)
#4 {main}

Any hint?
Mediawiki 1.36
https://www.tematichedigenere.com/wiki/Speciale:Versione

I am getting new errors along these lines, when trying to upgrade to Mediawiki 1.38:

Fatal error: Wikibase\DataModel\Entity\SerializableEntityId cannot implement Wikibase\DataModel\Entity\EntityId - it is not an interface in /var/www/vhosts/bibleget.io/seminaverbi_1_38/w/extensions/Wikibase/lib/packages/wikibase/data-model/src/Entity/SerializableEntityId.php on line 11

I have tried running composer update --no-dev multiple times, I have made sure that all extensions are included in the root composer.local.json, I have tried running git submodule update --init --recursive, but nothing seems to be helping. Arghhh.

I'm getting the same

It happens when mediawiki/includes/AutoLoader.php attempts to require('/vagrant/mediawiki/extensions/Wikibase/lib/packages/wikibase/data-model/src/Entity/SerializableEntityId.php') ... I presume because EntityId hasn't been autoloaded yet. I don't really understand why the MW autoloader is getting used rather than composer

edit: actually this only happens when I the WikibaseImport extension enabled

I was able to solve the error EntityId is not an interface, see https://www.mediawiki.org/wiki/Topic:X2qyoagj0mx24oey

I had run composer update --no-dev in each extension's folder and not only in the root directory. This caused an older version of EntityId to be loaded. So I had to remove any vendor folders under the extension folders, and make sure composer update --no-dev was ONLY run in the root folder.

I am getting new errors along these lines, when trying to upgrade to Mediawiki 1.38:

Fatal error: Wikibase\DataModel\Entity\SerializableEntityId cannot implement Wikibase\DataModel\Entity\EntityId - it is not an interface in /var/www/vhosts/bibleget.io/seminaverbi_1_38/w/extensions/Wikibase/lib/packages/wikibase/data-model/src/Entity/SerializableEntityId.php on line 11

I have tried running composer update --no-dev multiple times, I have made sure that all extensions are included in the root composer.local.json, I have tried running git submodule update --init --recursive, but nothing seems to be helping. Arghhh.