Page MenuHomePhabricator

PHP Warning: Invalid argument supplied for foreach()
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error

MediaWiki version: 1.35.0-wmf.15

message
PHP Warning: Invalid argument supplied for foreach()

Impact

There's a few of these after I promoted 1.35.0-wmf.15 to all wikis half an hour ago. Not enough to warrant rollback, I think. Superficially, this looks similar to https://phabricator.wikimedia.org/T242856 which was fixed and backported yesterday, so adding Lucas as subscriber in case it's actually related.

Notes

https://logstash.wikimedia.org/goto/fe3b35077b0d42e7fcb13df47a4c2f6f for an example in logstash, for those who have access.

Details

Request ID
XiBzpgpAAEYAAIpGtHoAAAEN
Request URL
https://en.wikipedia.org/wiki/Special:GlobalRenameRequest
Stack Trace
exception.trace
#0 /srv/mediawiki/php-1.35.0-wmf.15/extensions/CentralAuth/includes/GlobalRename/GlobalRenameBlacklist.php(127): MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /srv/mediawiki/php-1.35.0-wmf.15/extensions/CentralAuth/includes/specials/SpecialGlobalRenameRequest.php(40): GlobalRenameBlacklist->checkUser(User)
#2 /srv/mediawiki/php-1.35.0-wmf.15/includes/specialpage/SpecialPage.php(316): SpecialGlobalRenameRequest->userCanExecute(User)
#3 /srv/mediawiki/php-1.35.0-wmf.15/includes/specialpage/FormSpecialPage.php(207): SpecialPage->checkPermissions()
#4 /srv/mediawiki/php-1.35.0-wmf.15/includes/specialpage/FormSpecialPage.php(179): FormSpecialPage->checkExecutePermissions(User)
#5 /srv/mediawiki/php-1.35.0-wmf.15/extensions/CentralAuth/includes/specials/SpecialGlobalRenameRequest.php(98): FormSpecialPage->execute(NULL)
#6 /srv/mediawiki/php-1.35.0-wmf.15/includes/specialpage/SpecialPage.php(575): SpecialGlobalRenameRequest->execute(NULL)
#7 /srv/mediawiki/php-1.35.0-wmf.15/includes/specialpage/SpecialPageFactory.php(611): SpecialPage->run(NULL)
#8 /srv/mediawiki/php-1.35.0-wmf.15/includes/MediaWiki.php(298): MediaWiki\Special\SpecialPageFactory->executePath(Title, RequestContext)
#9 /srv/mediawiki/php-1.35.0-wmf.15/includes/MediaWiki.php(967): MediaWiki->performRequest()
#10 /srv/mediawiki/php-1.35.0-wmf.15/includes/MediaWiki.php(530): MediaWiki->main()
#11 /srv/mediawiki/php-1.35.0-wmf.15/index.php(46): MediaWiki->run()
#12 /srv/mediawiki/w/index.php(3): require(string)
#13 {main}

Event Timeline

GlobalRenameBlacklist in the stack trace sounds like T101615, SWATed earlier today by @Urbanecm:

Mentioned in SAL (#wikimedia-operations) [2020-01-16T12:33:39Z] <urbanecm@deploy1001> Synchronized wmf-config/InitialiseSettings.php: SWAT: 65e17eb: Configure GlobalRename blacklist (T101615) (duration: 01m 05s)

If I read the code correctly, this warning will happen when the blacklist is empty. GlobalRenameBlacklist’s $this->blacklist is never explicitly set (other than its null default), it’s just appended to:

foreach ( $rows as $row ) {
	// ...
	$this->blacklist[] = $trimmedRow;
}

The appending works (because of PHP’s type juggling or whatever the correct terminology is), but if there are no $rows, then the blacklist will still be null rather than [].

Change 565295 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/CentralAuth@master] Initialize blacklist even if empty

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

Change 565295 merged by jenkins-bot:
[mediawiki/extensions/CentralAuth@master] Initialize blacklist even if empty

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

Change 565362 had a related patch set uploaded (by Jforrester; owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/CentralAuth@wmf/1.35.0-wmf.15] Initialize blacklist even if empty

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

Change 565362 merged by jenkins-bot:
[mediawiki/extensions/CentralAuth@wmf/1.35.0-wmf.15] Initialize blacklist even if empty

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

Mentioned in SAL (#wikimedia-operations) [2020-01-16T20:29:26Z] <jforrester@deploy1001> Synchronized php-1.35.0-wmf.15/extensions/CentralAuth/includes/GlobalRename/GlobalRenameBlacklist.php: Special:GlobalRenameRequest: Initialize blacklist even if empty T242974 (duration: 00m 57s)