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
This commit is contained in:
Daimona Eaytoy 2019-12-10 16:36:28 +01:00
parent f443eb8533
commit 6be070e5a2

View file

@ -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 = [];