Don't publish LogEntries without ID

Mimic what publish() does, for the part that we need.

Bug: T219951
Bug: T218940
Change-Id: I16dd7071837a6965934d08b770f455f45cd02a6b
This commit is contained in:
Daimona Eaytoy 2019-03-28 14:19:52 +01:00
parent 7f5b3dd23e
commit a777b681e2

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