Page MenuHomePhabricator

Argument 4 passed to MediaWiki\Extensions\WikibaseStatementUpdater\Updater\Updater::__construct() must be an instance of MediaWiki\OAuthClient\Token, null given
Closed, ResolvedPublic

Description

[YEI6guqy2Ttw5a-tYIOYIAAAAAY] [no req]   TypeError from line 25 of /data/srv/mediawiki/tags/2021-03-01_15:30:33/extensions/WikibaseStatementUpdater/src/Updater/Updater.php: Argument 4 passed to MediaWiki\Extensions\WikibaseStatementUpdater\Updater\Updater::__construct() must be an instance of MediaWiki\OAuthClient\Token, null given, called in /data/srv/mediawiki/tags/2021-03-01_15:30:33/extensions/WikibaseStatementUpdater/src/Updater/UpdateManager.php on line 57
#0 /data/srv/mediawiki/tags/2021-03-01_15:30:33/extensions/WikibaseStatementUpdater/src/Updater/UpdateManager.php(57): MediaWiki\Extensions\WikibaseStatementUpdater\Updater\Updater->__construct(MediaWiki\OAuthClient\Client, string, MediaWiki\Extensions\WikibaseStatementUpdater\Batch\BatchItem, NULL)
#1 /data/srv/mediawiki/tags/2021-03-01_15:30:33/extensions/WikibaseStatementUpdater/src/Updater/UpdateJob.php(31): MediaWiki\Extensions\WikibaseStatementUpdater\Updater\UpdateManager->process(integer, integer)
#2 /data/srv/mediawiki/tags/2021-03-01_15:30:33/includes/jobqueue/JobRunner.php(372): MediaWiki\Extensions\WikibaseStatementUpdater\Updater\UpdateJob->run()
#3 /data/srv/mediawiki/tags/2021-03-01_15:30:33/includes/jobqueue/JobRunner.php(333): JobRunner->doExecuteJob(MediaWiki\Extensions\WikibaseStatementUpdater\Updater\UpdateJob)
#4 /data/srv/mediawiki/tags/2021-03-01_15:30:33/includes/jobqueue/JobRunner.php(244): JobRunner->executeJob(MediaWiki\Extensions\WikibaseStatementUpdater\Updater\UpdateJob)
#5 /data/srv/mediawiki/tags/2021-03-01_15:30:33/maintenance/runJobs.php(92): JobRunner->run(array)
#6 /data/srv/mediawiki/tags/2021-03-01_15:30:33/maintenance/doMaintenance.php(107): RunJobs->execute()
#7 /data/srv/mediawiki/tags/2021-03-01_15:30:33/maintenance/runJobs.php(129): require_once(string)
#8 {main}

Event Timeline

Umherirrender subscribed.

That issue seems fixed (or only hidden), now failing with:

00:22:32 There was 1 error:
00:22:32 
00:22:32 1) SpecialPageFatalTest::testSpecialPageDoesNotFatal with data set "WikibaseStatementUpdater" ('WikibaseStatementUpdater')
00:22:32 Wikimedia\Services\ContainerDisabledException: Container disabled!
00:22:32 
00:22:32 /workspace/src/vendor/wikimedia/services/src/ServiceContainer.php:408
00:22:32 /workspace/src/includes/MediaWikiServices.php:264
00:22:32 /workspace/src/vendor/wikimedia/services/src/ServiceContainer.php:424
00:22:32 /workspace/src/extensions/WikibaseStatementUpdater/src/Services.php:38
00:22:32 /workspace/src/extensions/WikibaseStatementUpdater/src/Services.php:33
00:22:32 /workspace/src/extensions/WikibaseStatementUpdater/src/WikibaseStatementUpdaterSpecialPage.php:74
00:22:32 /workspace/src/vendor/wikimedia/object-factory/src/ObjectFactory.php:232
00:22:32 /workspace/src/vendor/wikimedia/object-factory/src/ObjectFactory.php:150
00:22:32 /workspace/src/includes/specialpage/SpecialPageFactory.php:1215
00:22:32 /workspace/src/tests/phpunit/structure/SpecialPageFatalTest.php:40
00:22:32 /workspace/src/tests/phpunit/MediaWikiIntegrationTestCase.php:449
00:22:32 === Logs generated by test case
00:22:32 [objectcache] [debug] MainWANObjectCache using store {class} {"class":"EmptyBagOStuff"}
00:22:32 [localisation] [debug] LocalisationCache using store LCStoreNull []
00:22:32 [localisation] [debug] LocalisationCache::isExpired(en): cache missing, need to make one []
00:22:32 ===

That looks like a different error to be honest, and not caused by WBSU. How would that test not fail on every special page which injects services via the constructor? The only difference I see is that I use a factory function instead of specifying class + services, because in extension.json it's not possible to inject LoggerFactory::getInstance( 'WikibaseStatementUpdater' ) or JobQueueGroup::singleton() as they are not standalone services.

Could someone help me figure out why SpecialPageFatalTest::testSpecialPageDoesNotFatal is failing for this extension? Shouldn't service container be enabled for integration tests? What is disabling it?

The problem is that you are retaining a reference to MWServices in a static instance variable. Between tests MWServices get destroyed, and so in the next test you have a reference to a destroyed MWServices instance.

You shouldn't cache Services in a static class variable. For an example of an approach to fix it see GrowthExperiments extension and GrowthExperimentsServices

I believe I understand what you are saying, but I am not sure exactly where in my code this happens. Would the cause be this line: https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/WikibaseStatementUpdater/+/76638fa7976260d6db566ea7f95931c537839b5b/src/Services.php#28 ? Though I just copied this from Translate and it doesn't seem to fail there.

The stack trace lists https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/WikibaseStatementUpdater/+/76638fa7976260d6db566ea7f95931c537839b5b/src/WikibaseStatementUpdaterSpecialPage.php#72 but there is no caching there.

I believe I understand what you are saying, but I am not sure exactly where in my code this happens. Would the cause be this line: https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/WikibaseStatementUpdater/+/76638fa7976260d6db566ea7f95931c537839b5b/src/Services.php#28 ? Though I just copied this from Translate and it doesn't seem to fail there.

Yes, that's the line. Sorry, should've been more specific. I guess in Translate you're just lucky, a large number of coincidences should occur for this issue to surface, but I'd suggest removing this caching in Translate as well.

BPirkle subscribed.

Sounds like this may be resolved. Moving to Tracking/Watching to be sure before Resolving.

Sounds like this may be resolved. Moving to Tracking/Watching to be sure before Resolving.

So, is it resolved?

Nikerabbit claimed this task.