Page MenuHomePhabricator

TypeError: MediaWiki\Permissions\UltimateAuthority::__construct(): Argument #1 ($actor) must be of type MediaWiki\User\UserIdentity, bool given
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
normalized_message
[{reqId}] {exception_url}   TypeError: MediaWiki\Permissions\UltimateAuthority::__construct(): Argument #1 ($actor) must be of type MediaWiki\User\UserIdentity, bool given, called in /srv/mediawiki/php-1.44.0-wmf.18/extensions/CentralAuth/includes/Hooks/H
FrameLocationCall
from/srv/mediawiki/php-1.44.0-wmf.18/includes/Permissions/UltimateAuthority.php(49)
#0/srv/mediawiki/php-1.44.0-wmf.18/extensions/CentralAuth/includes/Hooks/Handlers/UserGroupsHookHandler.php(87)MediaWiki\Permissions\UltimateAuthority->__construct(bool)
#1/srv/mediawiki/php-1.44.0-wmf.18/includes/HookContainer/HookContainer.php(155)MediaWiki\Extension\CentralAuth\Hooks\Handlers\UserGroupsHookHandler->onUserGroupsChanged(MediaWiki\User\User, array, array, bool, bool, array, array)
#2/srv/mediawiki/php-1.44.0-wmf.18/includes/HookContainer/HookRunner.php(4381)MediaWiki\HookContainer\HookContainer->run(string, array)
#3/srv/mediawiki/php-1.44.0-wmf.18/includes/user/UserGroupManager.php(725)MediaWiki\HookContainer\HookRunner->onUserGroupsChanged(MediaWiki\User\User, array, array, bool, bool, array, array)
#4/srv/mediawiki/php-1.44.0-wmf.18/includes/Storage/PageUpdater.php(982)MediaWiki\User\UserGroupManager->addUserToAutopromoteOnceGroups(MediaWiki\User\User, string)
#5/srv/mediawiki/php-1.44.0-wmf.18/includes/deferred/MWCallableUpdate.php(52)MediaWiki\Storage\PageUpdater->MediaWiki\Storage\{closure}(string)
#6/srv/mediawiki/php-1.44.0-wmf.18/includes/deferred/DeferredUpdates.php(459)MediaWiki\Deferred\MWCallableUpdate->doUpdate()
#7/srv/mediawiki/php-1.44.0-wmf.18/includes/deferred/DeferredUpdates.php(201)MediaWiki\Deferred\DeferredUpdates::attemptUpdate(MediaWiki\Deferred\MWCallableUpdate)
#8/srv/mediawiki/php-1.44.0-wmf.18/includes/deferred/DeferredUpdates.php(288)MediaWiki\Deferred\DeferredUpdates::run(MediaWiki\Deferred\MWCallableUpdate)
#9/srv/mediawiki/php-1.44.0-wmf.18/includes/deferred/DeferredUpdatesScope.php(243)MediaWiki\Deferred\DeferredUpdates::MediaWiki\Deferred\{closure}(MediaWiki\Deferred\MWCallableUpdate, int)
#10/srv/mediawiki/php-1.44.0-wmf.18/includes/deferred/DeferredUpdatesScope.php(172)MediaWiki\Deferred\DeferredUpdatesScope->processStageQueue(int, int, Closure)
#11/srv/mediawiki/php-1.44.0-wmf.18/includes/deferred/DeferredUpdates.php(307)MediaWiki\Deferred\DeferredUpdatesScope->processUpdates(int, Closure)
#12/srv/mediawiki/php-1.44.0-wmf.18/includes/MediaWikiEntryPoint.php(674)MediaWiki\Deferred\DeferredUpdates::doUpdates()
#13/srv/mediawiki/php-1.44.0-wmf.18/includes/MediaWikiEntryPoint.php(496)MediaWiki\MediaWikiEntryPoint->restInPeace()
#14/srv/mediawiki/php-1.44.0-wmf.18/includes/MediaWikiEntryPoint.php(454)MediaWiki\MediaWikiEntryPoint->doPostOutputShutdown()
#15/srv/mediawiki/php-1.44.0-wmf.18/includes/MediaWikiEntryPoint.php(211)MediaWiki\MediaWikiEntryPoint->postOutputShutdown()
#16/srv/mediawiki/php-1.44.0-wmf.18/index.php(58)MediaWiki\MediaWikiEntryPoint->run()
#17/srv/mediawiki/w/index.php(3)require(string)
#18{main}
Impact
Notes

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Reedy renamed this task from TypeError: MediaWiki\Permissions\UltimateAuthority::__construct(): Argument #1 ($actor) must be of type MediaWiki\User\UserIdentity, bool given, called in /srv/mediawiki/php-1.44.0-wmf.18/extensions/CentralAuth/includes/Hooks/H to TypeError: MediaWiki\Permissions\UltimateAuthority::__construct(): Argument #1 ($actor) must be of type MediaWiki\User\UserIdentity, bool given.Feb 27 2025, 9:25 PM
Reedy triaged this task as High priority.Feb 28 2025, 11:33 PM

Not sure if autopromotion should be ignored in this scope or if a different ultimate authority needs to be crafted (the user themself?).

The intent of the code is to consistently enforce that being in a local group associates with a global group, so it shouldn't be ignored. But what it should be logged as is unclear.

Also the code should probably short-circuit and not call the manager at all if no groups need to be added, which would fix this in production since the only use of this feature is CheckUser/Oversight -> global-temporary-account-viewer where autopromotion doesn't make sense.

https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+blame/refs/heads/wmf/1.44.0-wmf.18/includes/user/UserGroupManager.php#727

	722			// update groups in external authentication database
	723			// TODO: deprecate passing full User object to hook
	724			$this->hookRunner->onUserGroupsChanged(
	725				$userObj,
	726				$toPromote, [],
	727				false,
	728				false,
	729				$oldUGMs,
	730				$newUGMs
	731			);

It seems core has explicitly been passing false as the performer for a long time... rMWd00dfbd756fb: Move User::addAutopromoteOnceGroups to UserGroupManager

rECAU22122188e6b9: Update automatic global group membership on local group change introduced this handler that doesn't like the parameter. Part of T376315: Control access to global-temporary-account-viewer group on WMF wikis automatically

This was only merged recently, included in wmf/1.44.0-wmf.18

The short term fix for this is to return if the performer is not set, as this feature isn't yet being used. A more long term fix would be to use some kind of maintenance script user.

Change #1123771 had a related patch set uploaded (by Dreamy Jazz; author: Dreamy Jazz):

[mediawiki/extensions/CentralAuth@master] UserGroupsHookHandler: Return early if performer is false

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

Change #1123772 had a related patch set uploaded (by Dreamy Jazz; author: Dreamy Jazz):

[mediawiki/extensions/CentralAuth@wmf/1.44.0-wmf.18] UserGroupsHookHandler: Return early if performer is false

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

Created patches for the short-term fix. I've seen 446 of these errors in logstash, though it looks like it would prevent the edits by anyone who is just about to be autopromoted so it is problematic (as it essentially is blocking some users from making any edits). I'm not going to deploy the fix right now given that I don't think it appears to meet the criteria for an emergency deployment, but would not oppose anyone else doing that or asking for it to happen.

Change #1123772 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@wmf/1.44.0-wmf.18] UserGroupsHookHandler: Return early if performer is false

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

I went to check if the docs for this hook already document that $performer may be false in the case of autopromote.. and they are! so nothing to fix there either

	 * @param User|false $performer User who performed the change, false if via autopromotion

Mentioned in SAL (#wikimedia-operations) [2025-03-02T00:21:49Z] <reedy@deploy2002> Started scap sync-world: Backport for [[gerrit:1123772|UserGroupsHookHandler: Return early if performer is false (T387523)]]

Mentioned in SAL (#wikimedia-operations) [2025-03-02T00:25:48Z] <reedy@deploy2002> reedy, dreamyjazz: Backport for [[gerrit:1123772|UserGroupsHookHandler: Return early if performer is false (T387523)]] synced to the testservers (https://wikitech.wikimedia.org/wiki/Mwdebug)

Change #1123771 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@master] UserGroupsHookHandler: Return early if performer is false

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

Mentioned in SAL (#wikimedia-operations) [2025-03-02T00:32:23Z] <reedy@deploy2002> Finished scap sync-world: Backport for [[gerrit:1123772|UserGroupsHookHandler: Return early if performer is false (T387523)]] (duration: 10m 33s)

Reedy assigned this task to Dreamy_Jazz.