Page MenuHomePhabricator

PHPStan failing on Wikibase backports to REL1_40
Closed, ResolvedPublic

Description

On this real REL1_40 backport or this empty change to test CI, quibble-composer-mysql-php74-noselenium-docker is failing (empty change console):

> composer phpstan
> phpstan analyze -a ../../tests/phpunit/bootstrap.php

Fatal error: Uncaught Error: Interface 'Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface' not found in /workspace/src/includes/libs/Stats/IBufferingStatsdDataFactory.php:13
Stack trace:
#0 /workspace/src/includes/AutoLoader.php(220): require()
#1 [internal function]: AutoLoader::autoload()
#2 /workspace/src/includes/libs/Stats/NullStatsdDataFactory.php(10): spl_autoload_call()
#3 /workspace/src/includes/AutoLoader.php(220): require('/workspace/src/...')
#4 [internal function]: AutoLoader::autoload()
#5 /workspace/src/includes/libs/rdbms/TransactionProfiler.php(117): spl_autoload_call()
#6 /workspace/src/includes/profiler/Profiler.php(62): Wikimedia\Rdbms\TransactionProfiler->__construct()
#7 /workspace/src/includes/profiler/Profiler.php(101): Profiler->__construct()
#8 /workspace/src/tests/phpunit/bootstrap.php(99): Profiler::init()
#9 phar:///workspace/src/extensions/Wikibase/vendor/phpstan/phpstan/phpstan.phar/src/Command/CommandHelper.php(135): require_once('/workspace/src/...')
#10 phar:///workspace/src/extensi in /workspace/src/includes/libs/Stats/IBufferingStatsdDataFactory.php on line 13
PHP Fatal error:  Uncaught Error: Interface 'Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface' not found in /workspace/src/includes/libs/Stats/IBufferingStatsdDataFactory.php:13
Stack trace:
#0 /workspace/src/includes/AutoLoader.php(220): require()
#1 [internal function]: AutoLoader::autoload()
#2 /workspace/src/includes/libs/Stats/NullStatsdDataFactory.php(10): spl_autoload_call()
#3 /workspace/src/includes/AutoLoader.php(220): require('/workspace/src/...')
#4 [internal function]: AutoLoader::autoload()
#5 /workspace/src/includes/libs/rdbms/TransactionProfiler.php(117): spl_autoload_call()
#6 /workspace/src/includes/profiler/Profiler.php(62): Wikimedia\Rdbms\TransactionProfiler->__construct()
#7 /workspace/src/includes/profiler/Profiler.php(101): Profiler->__construct()
#8 /workspace/src/tests/phpunit/bootstrap.php(99): Profiler::init()
#9 phar:///workspace/src/extensions/Wikibase/vendor/phpstan/phpstan/phpstan.phar/src/Command/CommandHelper.php(135): require_once('/workspace/src/...')
#10 phar:///workspace/src/extensi in /workspace/src/includes/libs/Stats/IBufferingStatsdDataFactory.php on line 13
Script phpstan analyze -a ../../tests/phpunit/bootstrap.php handling the phpstan event returned with error code 255
Script composer phpstan handling the test event returned with error code 255

Event Timeline

This looks suspiciously like a repeat of T326653: PHPStan failing on Wikibase backports to wmf branches. Maybe @Jdforrester-WMF can take a look? It’s not super urgent (the backport I wanted to do just silences a log warning), but I tagged it with MW-1.40-release because I think being unable to merge changes on a release branch isn’t ideal in case there are more important changes later.

Trying to remember what happened in that task…

Apparently the CI job runs Wikibase’s composer test before installing MediaWiki core’s dependencies?

That still seems to be the case. composer test, in the Wikibase directory, installs Wikibase’s dependencies, but not those of MediaWiki core.

quibble-composer jobs are for release branches (and other circumstances where you're not aimed at Wikimedia production); they shouldn't ever be live on development or wmf/ branches.

That sounds like what we’re seeing here is actually correct, and not a CI misconfiguration. But I’m not sure what that means for us.

Do we need to add all composer packages that are used in Wikibase directly to Wikibase’s composer.json, instead of relying on MediaWiki core’s composer.json to install some of the dependencies?

Also, it’s probably worth mentioning that composer phpstan is new in composer test since 1.40, it doesn’t exist in 1.39 yet. So we don’t need to look for an explanation about the difference between 1.39 and 1.40, that part is clear IMHO – we just need to figure out how we can make this new thing work on REL1_40. (Or remove it, I suppose.)

Change 904540 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@master] DNM: Add dependencies

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

Change 904540 abandoned by Lucas Werkmeister (WMDE):

[mediawiki/extensions/Wikibase@master] DNM: Add dependencies

Reason:

wrong branch

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

Change 904541 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@REL1_40] DNM: Add dependencies

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

Do we need to add all composer packages that are used in Wikibase directly to Wikibase’s composer.json, instead of relying on MediaWiki core’s composer.json to install some of the dependencies?

Nope, doesn’t work. phpstan prints the following message (without a trailing newline, grmbl):

Could not find composer.lock file. Have you run "composer install --no-dev"?

strace reveals it’s looking for composer.lock in the MediaWiki core parent directory and its vendor/ subdirectory, where no composer lockfile exists because we never ran composer install there.

I feel like there’s a general mismatch here, between one side in CI which expects to be able to run composer test on an extension’s own Git repository without a broader MediaWiki setup, and between the other side in Wikibase which expects MediaWiki and its dependencies to have been installed when PHPStan runs. And I’m not sure how this can be reconciled… I thought there might be an alternative composer script that we could move the phpstan command into (instead of composer test), but I can’t see one in this CI output (from this REL1_40 OAuth change) at least.

This did work somehow till REL1_40 didn't it? What changed?

It works on master and wmf because those branches run different CI jobs than the release branches; and it works on earlier release branches because the phpstan part is new in 1.40.

Gotcha, I'm sorry, I glanced over the comment where you had already explained that above. My bad.

Tagging Wikibase Reuse Team since they added PHPStan.

If we can’t find another solution, I suggest we remove the composer phpstan command from composer test on REL1_40, to unblock CI. (Though this only kicks the can down the road: REL1_41 would have the same problem again.)

Change 904791 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@REL1_40] Remove phpstan from composer test

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

Change 904791 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@REL1_40] Remove phpstan from composer test

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

Wikibase REL1_40 CI works now. Not sure if we should close this task already, or leave it open until we find a better solution. (As it stands now, we’ll get the exact same problem once REL1_41 branches, and for future release branches after that too.)

Change 904541 abandoned by Lucas Werkmeister (WMDE):

[mediawiki/extensions/Wikibase@REL1_40] DNM: Add dependencies

Reason:

didn’t work out

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

Wikibase REL1_40 CI works now. Not sure if we should close this task already, or leave it open until we find a better solution. (As it stands now, we’ll get the exact same problem once REL1_41 branches, and for future release branches after that too.)

For now I've moved it so it's no longer blocking the release of MW 1.40.

Notes from task breakdown: We will try to find a way not to run phpstan on release branches.

Change 921251 had a related patch set uploaded (by Jakob; author: Jakob):

[mediawiki/extensions/Wikibase@master] Run PHPStan only if core dependencies installed

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

Change 921149 had a related patch set uploaded (by Jakob; author: Jakob):

[mediawiki/extensions/Wikibase@REL1_40] Run PHPStan only if core dependencies installed

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

Change 921251 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Run PHPStan only if core dependencies installed

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

Change 921149 abandoned by Jakob:

[mediawiki/extensions/Wikibase@REL1_40] Run PHPStan only if core dependencies installed

Reason:

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