Merge "Don't publish LogEntries without ID"

This commit is contained in:
jenkins-bot 2019-04-06 12:24:07 +00:00 committed by Gerrit Code Review
commit 8ac0dda62d

View file

@ -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