Page MenuHomePhabricator

No JavaScript on Beta due to PHP error in load.php: ArgumentCountError: array_merge() expects at least 1 parameter, 0 given
Closed, ResolvedPublic

Description

https://commons.wikimedia.beta.wmflabs.org/w/load.php?lang=en&modules=startup&only=scripts&raw=1&skin=vector


[YEKaM6wQBHcAAAZRhJUAAAAF] /w/load.php?lang=en&modules=startup&only=scripts&raw=1&skin=vector ArgumentCountError: array_merge() expects at least 1 parameter, 0 given

Backtrace:

from /srv/mediawiki/php-master/extensions/Wikibase/client/WikibaseClient.ServiceWiring.php(206)
#0 /srv/mediawiki/php-master/extensions/Wikibase/client/WikibaseClient.ServiceWiring.php(206): array_merge()
#1 /srv/mediawiki/php-master/vendor/wikimedia/services/src/ServiceContainer.php(447): Wikimedia\Services\ServiceContainer->{closure}(MediaWiki\MediaWikiServices)
#2 /srv/mediawiki/php-master/vendor/wikimedia/services/src/ServiceContainer.php(416): Wikimedia\Services\ServiceContainer->createService(string)
#3 /srv/mediawiki/php-master/includes/MediaWikiServices.php(261): Wikimedia\Services\ServiceContainer->getService(string)
#4 /srv/mediawiki/php-master/vendor/wikimedia/services/src/ServiceContainer.php(424): MediaWiki\MediaWikiServices->getService(string)
#5 /srv/mediawiki/php-master/extensions/Wikibase/client/includes/WikibaseClient.php(649): Wikimedia\Services\ServiceContainer->get(string)
#6 /srv/mediawiki/php-master/extensions/Wikibase/client/includes/ClientHooks.php(245): Wikibase\Client\WikibaseClient::getSite()
#7 /srv/mediawiki/php-master/includes/libs/objectcache/BagOStuff.php(210): Wikibase\Client\ClientHooks::Wikibase\Client\{closure}(integer)
#8 /srv/mediawiki/php-master/extensions/Wikibase/client/includes/ClientHooks.php(256): BagOStuff->getWithSetCallback(string, integer, Closure, array)
#9 /srv/mediawiki/php-master/includes/resourceloader/ResourceLoaderFileModule.php(1266): Wikibase\Client\ClientHooks::getSiteConfiguration(ResourceLoaderContext, GlobalVarConfig, NULL)
#10 /srv/mediawiki/php-master/includes/resourceloader/ResourceLoaderFileModule.php(632): ResourceLoaderFileModule->expandPackageFiles(ResourceLoaderContext)
#11 /srv/mediawiki/php-master/includes/resourceloader/ResourceLoaderModule.php(845): ResourceLoaderFileModule->getDefinitionSummary(ResourceLoaderContext)
#12 /srv/mediawiki/php-master/includes/resourceloader/ResourceLoaderStartUpModule.php(209): ResourceLoaderModule->getVersionHash(ResourceLoaderContext)
#13 /srv/mediawiki/php-master/includes/resourceloader/ResourceLoaderStartUpModule.php(405): ResourceLoaderStartUpModule->getModuleRegistrations(ResourceLoaderContext)
#14 /srv/mediawiki/php-master/includes/resourceloader/ResourceLoaderModule.php(739): ResourceLoaderStartUpModule->getScript(ResourceLoaderContext)
#15 /srv/mediawiki/php-master/includes/resourceloader/ResourceLoaderModule.php(707): ResourceLoaderModule->buildContent(ResourceLoaderContext)
#16 /srv/mediawiki/php-master/includes/resourceloader/ResourceLoaderModule.php(842): ResourceLoaderModule->getModuleContent(ResourceLoaderContext)
#17 /srv/mediawiki/php-master/includes/resourceloader/ResourceLoader.php(776): ResourceLoaderModule->getVersionHash(ResourceLoaderContext)
#18 [internal function]: ResourceLoader->{closure}(string)
#19 /srv/mediawiki/php-master/includes/resourceloader/ResourceLoader.php(788): array_map(Closure, array)
#20 /srv/mediawiki/php-master/includes/resourceloader/ResourceLoader.php(875): ResourceLoader->getCombinedVersion(ResourceLoaderContext, array)
#21 /srv/mediawiki/php-master/load.php(51): ResourceLoader->respond(ResourceLoaderContext)
#22 /srv/mediawiki/php-master/load.php(38): wfLoadMain()
#23 /srv/mediawiki/w/load.php(3): require(string)
#24 {main}

https://wikidata.beta.wmflabs.org/w/load.php?lang=en&modules=startup&only=scripts&raw=1&skin=vector


[YEKaLqwQBHcAAAZRhJQAAAAN] /w/load.php?lang=en&modules=startup&only=scripts&raw=1&skin=vector ArgumentCountError: array_merge() expects at least 1 parameter, 0 given

Backtrace:

from /srv/mediawiki/php-master/extensions/Wikibase/client/WikibaseClient.ServiceWiring.php(206)
#0 /srv/mediawiki/php-master/extensions/Wikibase/client/WikibaseClient.ServiceWiring.php(206): array_merge()
#1 /srv/mediawiki/php-master/vendor/wikimedia/services/src/ServiceContainer.php(447): Wikimedia\Services\ServiceContainer->{closure}(MediaWiki\MediaWikiServices)
#2 /srv/mediawiki/php-master/vendor/wikimedia/services/src/ServiceContainer.php(416): Wikimedia\Services\ServiceContainer->createService(string)
#3 /srv/mediawiki/php-master/includes/MediaWikiServices.php(261): Wikimedia\Services\ServiceContainer->getService(string)
#4 /srv/mediawiki/php-master/vendor/wikimedia/services/src/ServiceContainer.php(424): MediaWiki\MediaWikiServices->getService(string)
#5 /srv/mediawiki/php-master/extensions/Wikibase/client/includes/WikibaseClient.php(649): Wikimedia\Services\ServiceContainer->get(string)
#6 /srv/mediawiki/php-master/extensions/Wikibase/client/includes/ClientHooks.php(245): Wikibase\Client\WikibaseClient::getSite()
#7 /srv/mediawiki/php-master/includes/libs/objectcache/BagOStuff.php(210): Wikibase\Client\ClientHooks::Wikibase\Client\{closure}(integer)
#8 /srv/mediawiki/php-master/extensions/Wikibase/client/includes/ClientHooks.php(256): BagOStuff->getWithSetCallback(string, integer, Closure, array)
#9 /srv/mediawiki/php-master/includes/resourceloader/ResourceLoaderFileModule.php(1266): Wikibase\Client\ClientHooks::getSiteConfiguration(ResourceLoaderContext, GlobalVarConfig, NULL)
#10 /srv/mediawiki/php-master/includes/resourceloader/ResourceLoaderFileModule.php(632): ResourceLoaderFileModule->expandPackageFiles(ResourceLoaderContext)
#11 /srv/mediawiki/php-master/includes/resourceloader/ResourceLoaderModule.php(845): ResourceLoaderFileModule->getDefinitionSummary(ResourceLoaderContext)
#12 /srv/mediawiki/php-master/includes/resourceloader/ResourceLoaderStartUpModule.php(209): ResourceLoaderModule->getVersionHash(ResourceLoaderContext)
#13 /srv/mediawiki/php-master/includes/resourceloader/ResourceLoaderStartUpModule.php(405): ResourceLoaderStartUpModule->getModuleRegistrations(ResourceLoaderContext)
#14 /srv/mediawiki/php-master/includes/resourceloader/ResourceLoaderModule.php(739): ResourceLoaderStartUpModule->getScript(ResourceLoaderContext)
#15 /srv/mediawiki/php-master/includes/resourceloader/ResourceLoaderModule.php(707): ResourceLoaderModule->buildContent(ResourceLoaderContext)
#16 /srv/mediawiki/php-master/includes/resourceloader/ResourceLoaderModule.php(842): ResourceLoaderModule->getModuleContent(ResourceLoaderContext)
#17 /srv/mediawiki/php-master/includes/resourceloader/ResourceLoader.php(776): ResourceLoaderModule->getVersionHash(ResourceLoaderContext)
#18 [internal function]: ResourceLoader->{closure}(string)
#19 /srv/mediawiki/php-master/includes/resourceloader/ResourceLoader.php(788): array_map(Closure, array)
#20 /srv/mediawiki/php-master/includes/resourceloader/ResourceLoader.php(875): ResourceLoader->getCombinedVersion(ResourceLoaderContext, array)
#21 /srv/mediawiki/php-master/load.php(51): ResourceLoader->respond(ResourceLoaderContext)
#22 /srv/mediawiki/php-master/load.php(38): wfLoadMain()
#23 /srv/mediawiki/w/load.php(3): require(string)
#24 {main}

I think I remember this code, it’s probably me who broke it. Just a second.

Event Timeline

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

Yeah, the local site on Wikidata (and presumably others too) has no local IDs:

on deployment-mediawiki-07
>>> $globalId = $settings->getSetting( 'siteGlobalID' )
=> "wikidatawiki"
>>> $site = $mws->getSiteLookup()->getSite( $globalId )
=> MediaWikiSite {#4103}
>>> $site->getLocalIds()
=> []
>>> var_export( $site )
MediaWikiSite::__set_state(array(
   'globalId' => 'wikidatawiki',
   'type' => 'mediawiki',
   'group' => 'wikidata',
   'source' => 'local',
   'languageCode' => 'en',
   'localIds' => 
  array (
  ),
   'extraData' => 
  array (
    'paths' => 
    array (
      'file_path' => 'https://wikidata.beta.wmflabs.org/w/$1',
      'page_path' => 'https://wikidata.beta.wmflabs.org/wiki/$1',
    ),
  ),
   'extraConfig' => 
  array (
  ),
   'forward' => false,
   'internalId' => 41,
))⏎
=> null

Which means my array_merge( ...array_values( $site->getLocalIds() ) ) from T276349 / https://gerrit.wikimedia.org/r/c/668377 breaks.

The good news is this looks like it wouldn’t happen in prod:

on mwdebug1001
>>> $globalId = $settings->getSetting( 'siteGlobalID' );
=> "wikidatawiki"
>>> $site = $services->getSiteLookup()->getSite( $globalId );
=> MediaWikiSite {#4132}
>>> $site->getLocalIds()
=> [
     "interwiki" => [
       "wikidata",
     ],
   ]

Change 668781 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Protect against calling array_merge() without arguments

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

Change 668782 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] DNM: remove bugfix to check that test catches it

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

Change 668782 abandoned by Lucas Werkmeister (WMDE):
[mediawiki/extensions/Wikibase@master] DNM: remove bugfix to check that test catches it

Reason:
test successfully confirmed

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

The good news is this looks like it wouldn’t happen in prod:

…but let’s still mark this as a train blocker just in case, because I wouldn’t want to bet that this condition holds across all 900 or so client wikis where this code is used.

Also, March 8 is a bank holiday in Berlin, so WMDE staff might not get around to merge the fix before the branch is cut on Monday.

Change 668781 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Protect against calling array_merge() without arguments

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

Lucas_Werkmeister_WMDE added a subscriber: Legoktm.

Fix was deployed to Beta now, JS is back. Thanks a lot to @Legoktm for merging!