From a777b681e233f2c5a8ed19d6dc22f150f8a7e1b2 Mon Sep 17 00:00:00 2001 From: Daimona Eaytoy Date: Thu, 28 Mar 2019 14:19:52 +0100 Subject: [PATCH] Don't publish LogEntries without ID Mimic what publish() does, for the part that we need. Bug: T219951 Bug: T218940 Change-Id: I16dd7071837a6965934d08b770f455f45cd02a6b --- includes/AbuseFilter.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/includes/AbuseFilter.php b/includes/AbuseFilter.php index d70e61cd2..41f2f51a4 100644 --- a/includes/AbuseFilter.php +++ b/includes/AbuseFilter.php @@ -1458,7 +1458,7 @@ class AbuseFilter { if ( self::filterHidden( $data['afl_filter'] ) && !$wgAbuseFilterNotificationsPrivate ) { continue; } - $entry->publish( 0, $wgAbuseFilterNotifications ); + self::publishEntry( $dbw, $entry, $wgAbuseFilterNotifications ); } } @@ -1513,6 +1513,31 @@ class AbuseFilter { self::checkEmergencyDisable( $group, $logged_local_filters ); } + /** + * Like LogEntry::publish, but doesn't require an ID (which we don't have) and skips the + * tagging part + * + * @param IDatabase $dbw To cancel the callback if the log insertion fails + * @param ManualLogEntry $entry + * @param string $to One of 'udp', 'rc' and 'rcandudp' + */ + private static function publishEntry( IDatabase $dbw, ManualLogEntry $entry, $to ) { + DeferredUpdates::addCallableUpdate( + function () use ( $entry, $to ) { + $rc = $entry->getRecentChange(); + + if ( $to === 'rc' || $to === 'rcandudp' ) { + $rc->save( $rc::SEND_NONE ); + } + if ( $to === 'udp' || $to === 'rcandudp' ) { + $rc->notifyRCFeeds(); + } + }, + DeferredUpdates::POSTSEND, + $dbw + ); + } + /** * Store a var dump to External Storage or the text table * Some of this code is stolen from Revision::insertOn and friends