From 6be070e5a2b2e1d39f1130ddf5b1157413819fc4 Mon Sep 17 00:00:00 2001 From: Daimona Eaytoy Date: Tue, 10 Dec 2019 16:36:28 +0100 Subject: [PATCH] Strengthen the check for null edits Even if the Content objects are different, the normalized text contents may be identical. Also, stop misattributing null edits by adding the last revision of the page as afl_rev_id. Bug: T240115 Change-Id: I3fb7b36ab38ca1544889a4c233b8ffdfc6c80936 --- includes/AbuseFilterHooks.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/includes/AbuseFilterHooks.php b/includes/AbuseFilterHooks.php index d529d4ef4..dbc04a6b2 100644 --- a/includes/AbuseFilterHooks.php +++ b/includes/AbuseFilterHooks.php @@ -163,14 +163,12 @@ class AbuseFilterHooks { $articleCacheKey = $title->getNamespace() . ':' . $title->getText(); AFComputedVariable::$articleCache[$articleCacheKey] = $page; - // Don't trigger for null edits. - if ( $oldContent ) { - // Compare Content objects if available - if ( $content->equals( $oldContent ) ) { - return null; - } - } elseif ( strcmp( $oldAfText, $text ) === 0 ) { - // Otherwise, compare strings + // Don't trigger for null edits. Compare Content objects if available, but check the + // stringified contents as well, e.g. for line endings normalization (T240115) + if ( + ( $oldContent && $content->equals( $oldContent ) ) || + strcmp( $oldAfText, $text ) === 0 + ) { return null; } } else { @@ -314,7 +312,9 @@ class AbuseFilterHooks { ) { $curTitle = $wikiPage->getTitle()->getPrefixedText(); if ( !isset( AbuseFilter::$logIds[ $curTitle ] ) || - $wikiPage !== self::$lastEditPage + $wikiPage !== self::$lastEditPage || + // Null edit. Too bad that there's no other way to recognize them. + $status->hasMessage( 'edit-no-change' ) ) { // This isn't the edit AbuseFilter::$logIds was set for AbuseFilter::$logIds = [];