Page MenuHomePhabricator

PHP Warning: Undefined array key "wikimedia-donor"
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
message
PHP Warning: Undefined array key "wikimedia-donor"
trace
from /srv/mediawiki/php-1.47.0-wmf.2/extensions/GlobalPreferences/includes/GlobalPreferencesFactory.php(462)
#0 /srv/mediawiki/php-1.47.0-wmf.2/extensions/GlobalPreferences/includes/GlobalPreferencesFactory.php(462): MediaWiki\Exception\MWExceptionHandler::handleError(int, string, string, int)
#1 /srv/mediawiki/php-1.47.0-wmf.2/includes/Preferences/DefaultPreferencesFactory.php(2202): GlobalPreferences\GlobalPreferencesFactory->saveFormData(array, GlobalPreferences\GlobalPreferencesFormOOUI, array)
#2 /srv/mediawiki/php-1.47.0-wmf.2/includes/Preferences/DefaultPreferencesFactory.php(2076): MediaWiki\Preferences\DefaultPreferencesFactory->submitForm(array, GlobalPreferences\GlobalPreferencesFormOOUI, array)
#3 /srv/mediawiki/php-1.47.0-wmf.2/includes/HTMLForm/HTMLForm.php(825): MediaWiki\Preferences\DefaultPreferencesFactory->MediaWiki\Preferences\{closure}(array, GlobalPreferences\GlobalPreferencesFormOOUI)
#4 /srv/mediawiki/php-1.47.0-wmf.2/includes/HTMLForm/HTMLForm.php(674): MediaWiki\HTMLForm\HTMLForm->trySubmit()
#5 /srv/mediawiki/php-1.47.0-wmf.2/includes/HTMLForm/HTMLForm.php(722): MediaWiki\HTMLForm\HTMLForm->tryAuthorizedSubmit()
#6 /srv/mediawiki/php-1.47.0-wmf.2/includes/Specials/SpecialPreferences.php(123): MediaWiki\HTMLForm\HTMLForm->show()
#7 /srv/mediawiki/php-1.47.0-wmf.2/extensions/GlobalPreferences/includes/SpecialGlobalPreferences.php(64): MediaWiki\Specials\SpecialPreferences->execute(null)
#8 /srv/mediawiki/php-1.47.0-wmf.2/includes/SpecialPage/SpecialPage.php(727): GlobalPreferences\SpecialGlobalPreferences->execute(null)
#9 /srv/mediawiki/php-1.47.0-wmf.2/includes/SpecialPage/SpecialPageFactory.php(1729): MediaWiki\SpecialPage\SpecialPage->run(null)
#10 /srv/mediawiki/php-1.47.0-wmf.2/includes/Actions/ActionEntryPoint.php(505): MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, MediaWiki\Context\RequestContext)
#11 /srv/mediawiki/php-1.47.0-wmf.2/includes/Actions/ActionEntryPoint.php(145): MediaWiki\Actions\ActionEntryPoint->performRequest()
#12 /srv/mediawiki/php-1.47.0-wmf.2/includes/MediaWikiEntryPoint.php(180): MediaWiki\Actions\ActionEntryPoint->execute()
#13 /srv/mediawiki/php-1.47.0-wmf.2/index.php(44): MediaWiki\MediaWikiEntryPoint->run()
#14 /srv/mediawiki/w/index.php(3): require(string)
#15 {main}
Impact

Thousands of PHP warnings, unclear if there is any other impact

Event Timeline

Jdlrobson-WMF subscribed.

I'll take a look at what's happening here.

Looks like a side effect of the T424908 fix (Gerrit 1282367). It removed the isAutoGlobal() bypass from isGlobalizablePreference() but saveFormData() still unconditionally accesses $formData[$name] for every auto-global.

Change #1289444 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/GlobalPreferences@master] Revert "GlobalPreferencesFactory: don't include hidden auto-globals in the form"

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

Just opening the above n the event the new warning is worse than the warning this fixed. I haven't had a chance to look at this and replicate locally but hopefully another solution would be to use isset.
Something like:

foreach ( $this->autoGlobals as $name ) {
		if ( isset( $formData[$name] ) {
			$prefs[ $name ] = $formData[$name];
		}
}

This seems to have become more common with array keys 0/1/4 recently (screenshot is over the past hour):

image.png (911×280 px, 73 KB)

Seems to have increased shortly after midnight UTC, judging by logstash (screenshot is over the last 24 hours):
image.png (678×274 px, 18 KB)

AFAICT the stack traces still implicate GlobalPreferencesFactory.

Dropping another variant here for searchability:

Error
  • mwversion: 1.47.0-wmf.2
  • timestamp: 2026-05-20T20:36:39.375Z
  • phpversion: 8.3.31
  • reqId: cabe5473-e4be-4714-a499-bdb9240b0c1f
  • Find reqId in Logstash
normalized_message
[{reqId}] {exception_url}   PHP Warning: Undefined array key "email-blacklist"
FrameLocationCall
from/srv/mediawiki/php-1.47.0-wmf.2/extensions/GlobalPreferences/includes/GlobalPreferencesFactory.php(462)
#0/srv/mediawiki/php-1.47.0-wmf.2/extensions/GlobalPreferences/includes/GlobalPreferencesFactory.php(462)MediaWiki\Exception\MWExceptionHandler::handleError(int, string, string, int)
#1/srv/mediawiki/php-1.47.0-wmf.2/includes/Preferences/DefaultPreferencesFactory.php(2202)GlobalPreferences\GlobalPreferencesFactory->saveFormData(array, GlobalPreferences\GlobalPreferencesFormOOUI, array)
#2/srv/mediawiki/php-1.47.0-wmf.2/includes/Preferences/DefaultPreferencesFactory.php(2076)MediaWiki\Preferences\DefaultPreferencesFactory->submitForm(array, GlobalPreferences\GlobalPreferencesFormOOUI, array)
#3/srv/mediawiki/php-1.47.0-wmf.2/includes/HTMLForm/HTMLForm.php(825)MediaWiki\Preferences\DefaultPreferencesFactory->MediaWiki\Preferences\{closure}(array, GlobalPreferences\GlobalPreferencesFormOOUI)
#4/srv/mediawiki/php-1.47.0-wmf.2/includes/HTMLForm/HTMLForm.php(674)MediaWiki\HTMLForm\HTMLForm->trySubmit()
#5/srv/mediawiki/php-1.47.0-wmf.2/includes/HTMLForm/HTMLForm.php(722)MediaWiki\HTMLForm\HTMLForm->tryAuthorizedSubmit()
#6/srv/mediawiki/php-1.47.0-wmf.2/includes/Specials/SpecialPreferences.php(123)MediaWiki\HTMLForm\HTMLForm->show()
#7/srv/mediawiki/php-1.47.0-wmf.2/extensions/GlobalPreferences/includes/SpecialGlobalPreferences.php(64)MediaWiki\Specials\SpecialPreferences->execute(null)
#8/srv/mediawiki/php-1.47.0-wmf.2/includes/SpecialPage/SpecialPage.php(727)GlobalPreferences\SpecialGlobalPreferences->execute(null)
#9/srv/mediawiki/php-1.47.0-wmf.2/includes/SpecialPage/SpecialPageFactory.php(1729)MediaWiki\SpecialPage\SpecialPage->run(null)
#10/srv/mediawiki/php-1.47.0-wmf.2/includes/Actions/ActionEntryPoint.php(505)MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, MediaWiki\Context\RequestContext)
#11/srv/mediawiki/php-1.47.0-wmf.2/includes/Actions/ActionEntryPoint.php(145)MediaWiki\Actions\ActionEntryPoint->performRequest()
#12/srv/mediawiki/php-1.47.0-wmf.2/includes/MediaWikiEntryPoint.php(180)MediaWiki\Actions\ActionEntryPoint->execute()
#13/srv/mediawiki/php-1.47.0-wmf.2/index.php(44)MediaWiki\MediaWikiEntryPoint->run()
#14/srv/mediawiki/w/index.php(3)require(string)
#15{main}

Change #1293670 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/extensions/GlobalPreferences@master] GlobalPreferencesFactory: do existence check when copying auto-globals

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

I still wonder if wikimedia-donor should be of type api instead of hidden, given the way it is set, but regardless using isset() fixes the warning. I was able to confirm this locally. The warning only happened on save and isn't echo'd to the output, so you'd need to look at i.e. cache/mw-error.log (for MediaWiki-Docker).

Change #1293670 merged by jenkins-bot:

[mediawiki/extensions/GlobalPreferences@master] GlobalPreferencesFactory: do existence check when copying auto-globals

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

Change #1289444 abandoned by Jdlrobson:

[mediawiki/extensions/GlobalPreferences@master] Revert "GlobalPreferencesFactory: don't include hidden auto-globals in the form"

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

MusikAnimal claimed this task.

No errors after June 4