From f3c87749b8b2f0350101aa5bb645ac5828bc6fc5 Mon Sep 17 00:00:00 2001 From: Dreamy Jazz Date: Wed, 28 Feb 2024 00:12:40 +0000 Subject: [PATCH] Send AbuseFilter logs to CheckUser on PRESEND Why: * AbuseFilter can send AbuseFilter logs to CheckUser if they are not being sent to Special:RecentChanges. * However, if this action is indirectly causing the creation of an account (such as through temporary account auto-creation), the log entry is sent to CheckUser before the temporary account actually exists in the 'user' table. * This causes a CannotCreateActorException, as the performer does not exist on the wiki just yet and therefore cannot have an actor ID until the temporary account is created. * This exception can happen if the AbuseFilter filter only creates a log entry and does not prevent the edit, so would not be necessarily fixed by T334623. * Sending the logs to CheckUser on PRESEND avoids this, as the user will exist by the time that PRESEND is run but still allows any failures to cause an exception which can be seen by the user. What: * Wrap the call to Hooks::updateCheckUserData in AbuseLogger ::insertLocalLogEntries in a DeferredUpdate which is set to run on PRESEND. Bug: T358632 Change-Id: Ia615fce3e26b88d5457ecc01231044b326b79973 --- includes/AbuseLogger.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/includes/AbuseLogger.php b/includes/AbuseLogger.php index 124d5da76..291e0af21 100644 --- a/includes/AbuseLogger.php +++ b/includes/AbuseLogger.php @@ -248,7 +248,12 @@ class AbuseLogger { $entry->setPerformer( new UserIdentityValue( 0, $this->requestIP ) ); } $rc = $entry->getRecentChange(); - Hooks::updateCheckUserData( $rc ); + // We need to send the entries on PRESEND to ensure that the user definitely exists. + // A temporary account being created through an edit will not exist until after AbuseFilter + // processes the edit and attempts to log to CheckUser. + DeferredUpdates::addCallableUpdate( static function () use ( $rc ) { + Hooks::updateCheckUserData( $rc ); + }, DeferredUpdates::PRESEND ); } if ( $this->options->get( 'AbuseFilterNotifications' ) !== false ) {