Page MenuHomePhabricator

"Call to a member function equals() on null" when rolling back a change with a suppressed username
Closed, ResolvedPublicPRODUCTION ERROR

Description

Seen by @Dogu when trying to do a rollback on `https://tr.wikipedia.org/wiki/1,1,1-Trikloroetan after an edit with a suppressed username.

Error
normalized_message
[{reqId}] {exception_url}   Error: Call to a member function equals() on null
exception.trace
from /srv/mediawiki/php-1.43.0-wmf.13/extensions/AutoModerator/src/RevisionCheck.php(270)
#0 /srv/mediawiki/php-1.43.0-wmf.13/extensions/AutoModerator/src/Hooks/RevisionFromEditCompleteHookHandler.php(121): AutoModerator\RevisionCheck::revertPreCheck(MediaWiki\User\User, MediaWiki\User\User, Monolog\Logger, MediaWiki\Revision\RevisionStore, array, MediaWiki\Permissions\RestrictionStore, MediaWiki\Page\WikiPageFactory, MediaWiki\User\UserGroupManager, AutoModerator\Config\AutoModeratorWikiConfigLoader, integer, integer)
#1 /srv/mediawiki/php-1.43.0-wmf.13/extensions/AutoModerator/src/Hooks.php(89): AutoModerator\Hooks\RevisionFromEditCompleteHookHandler->handle(WikiPage, MediaWiki\Revision\RevisionStoreRecord, integer, MediaWiki\User\User, array)
#2 /srv/mediawiki/php-1.43.0-wmf.13/includes/HookContainer/HookContainer.php(159): AutoModerator\Hooks->onRevisionFromEditComplete(WikiPage, MediaWiki\Revision\RevisionStoreRecord, integer, MediaWiki\User\User, array)
#3 /srv/mediawiki/php-1.43.0-wmf.13/includes/HookContainer/HookRunner.php(3290): MediaWiki\HookContainer\HookContainer->run(string, array)
#4 /srv/mediawiki/php-1.43.0-wmf.13/includes/Storage/PageUpdater.php(1387): MediaWiki\HookContainer\HookRunner->onRevisionFromEditComplete(WikiPage, MediaWiki\Revision\RevisionStoreRecord, integer, MediaWiki\User\User, array)
#5 /srv/mediawiki/php-1.43.0-wmf.13/includes/Storage/PageUpdater.php(923): MediaWiki\Storage\PageUpdater->doModify(MediaWiki\CommentStore\CommentStoreComment)
#6 /srv/mediawiki/php-1.43.0-wmf.13/includes/page/RollbackPage.php(319): MediaWiki\Storage\PageUpdater->saveRevision(MediaWiki\CommentStore\CommentStoreComment, integer)
#7 /srv/mediawiki/php-1.43.0-wmf.13/includes/page/RollbackPage.php(198): MediaWiki\Page\RollbackPage->rollback()
#8 /srv/mediawiki/php-1.43.0-wmf.13/includes/actions/RollbackAction.php(188): MediaWiki\Page\RollbackPage->rollbackIfAllowed()
#9 /srv/mediawiki/php-1.43.0-wmf.13/includes/actions/RollbackAction.php(136): RollbackAction->handleRollbackRequest()
#10 /srv/mediawiki/php-1.43.0-wmf.13/includes/actions/ActionEntryPoint.php(731): RollbackAction->show()
#11 /srv/mediawiki/php-1.43.0-wmf.13/includes/actions/ActionEntryPoint.php(508): MediaWiki\Actions\ActionEntryPoint->performAction(Article, MediaWiki\Title\Title)
#12 /srv/mediawiki/php-1.43.0-wmf.13/includes/actions/ActionEntryPoint.php(145): MediaWiki\Actions\ActionEntryPoint->performRequest()
#13 /srv/mediawiki/php-1.43.0-wmf.13/includes/MediaWikiEntryPoint.php(200): MediaWiki\Actions\ActionEntryPoint->execute()
#14 /srv/mediawiki/php-1.43.0-wmf.13/index.php(58): MediaWiki\MediaWikiEntryPoint->run()
#15 /srv/mediawiki/w/index.php(3): require(string)
#16 {main}

Impact

Prevents reverts of bad edits, both rollback and manual.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Scardenasmolinar changed the task status from Open to In Progress.Jul 16 2024, 7:09 PM
Scardenasmolinar claimed this task.
Scardenasmolinar triaged this task as High priority.
Scardenasmolinar moved this task from Ready to In Progress on the Moderator-Tools-Team (Kanban) board.

Since this is happening in the revision precheck, it, we should be able to stop the error immediately by disabling automoderator here:
https://tr.wikipedia.org/wiki/MediaWiki:AutoModeratorConfig.json
that would be something that @Dogu or another interface admin could do while we get a patch out

Awesome; can somebody try redoing an impacted revert to verify that things are mitigated?

@Scardenasmolinar
it looks like we're calling equals() on the return value of getUser() without checking to see if it actually returned a user. That seems like the most likely cuplrit:
https://codesearch.wmcloud.org/things/?q=equals&files=%5Esrc%5C%2F.%2B%5C.php%24&excludeFiles=&repos=Extension%3AAutoModerator

@Scardenasmolinar
it looks like we're calling equals() on the return value of getUser() without checking to see if it actually returned a user. That seems like the most likely cuplrit:
https://codesearch.wmcloud.org/things/?q=equals&files=%5Esrc%5C%2F.%2B%5C.php%24&excludeFiles=&repos=Extension%3AAutoModerator

Yes, I also reached the same conclusion. Our guard clause that checks for null users and revisions is not catching this. I have a fix incoming.

Change #1054675 had a related patch set uploaded (by Scardenasmolinar; author: Scardenasmolinar):

[mediawiki/extensions/AutoModerator@master] Fix guard clause in Revision Hook Handler

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

Change #1054675 merged by jenkins-bot:

[mediawiki/extensions/AutoModerator@master] Fix guard clause in Revision Hook Handler and Precheck

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

Change #1055274 had a related patch set uploaded (by Scardenasmolinar; author: Scardenasmolinar):

[mediawiki/extensions/AutoModerator@wmf/1.43.0-wmf.14] Fix guard clause in Revision Hook Handler and Precheck

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

Change #1055274 merged by jenkins-bot:

[mediawiki/extensions/AutoModerator@wmf/1.43.0-wmf.14] Fix guard clause in Revision Hook Handler and Precheck

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

Mentioned in SAL (#wikimedia-operations) [2024-07-18T21:02:18Z] <dancy@deploy1002> Started scap sync-world: Backport for [[gerrit:1055274|Fix guard clause in Revision Hook Handler and Precheck (T370161)]]

Mentioned in SAL (#wikimedia-operations) [2024-07-18T21:04:37Z] <dancy@deploy1002> suecarmol, dancy: Backport for [[gerrit:1055274|Fix guard clause in Revision Hook Handler and Precheck (T370161)]] synced to the testservers (https://wikitech.wikimedia.org/wiki/Mwdebug)

Mentioned in SAL (#wikimedia-operations) [2024-07-18T21:14:21Z] <dancy@deploy1002> Finished scap: Backport for [[gerrit:1055274|Fix guard clause in Revision Hook Handler and Precheck (T370161)]] (duration: 12m 02s)

@Dogu, we have made a backport to fix the error. You can now re-enable AutoModerator. If you see any new errors (or the same one) pop-up, let us know in this ticket.