diff --git a/includes/AbuseFilterChangesList.php b/includes/AbuseFilterChangesList.php index 4b0095f24..091e1302f 100644 --- a/includes/AbuseFilterChangesList.php +++ b/includes/AbuseFilterChangesList.php @@ -20,6 +20,11 @@ class AbuseFilterChangesList extends OldChangesList { */ private $testFilter; + /** + * @var array Maps RC IDs to a boolean indicating whether the RC would match a filter that is being tested + */ + private array $rcResults = []; + /** * @param IContextSource $context * @param string $testFilter @@ -51,7 +56,8 @@ class AbuseFilterChangesList extends OldChangesList { $examineParams['testfilter'] = $this->testFilter; } - $title = SpecialPage::getTitleFor( 'AbuseFilter', 'examine/' . $rc->getAttribute( 'rc_id' ) ); + $rcid = $rc->getAttribute( 'rc_id' ); + $title = SpecialPage::getTitleFor( 'AbuseFilter', 'examine/' . $rcid ); $examineLink = $this->linkRenderer->makeLink( $title, new HtmlArmor( $this->msg( 'abusefilter-changeslist-examine' )->parse() ), @@ -62,8 +68,8 @@ class AbuseFilterChangesList extends OldChangesList { $s .= ' ' . $this->msg( 'parentheses' )->rawParams( $examineLink )->escaped(); // Add CSS classes for match and not match - if ( isset( $rc->filterResult ) ) { - $class = $rc->filterResult ? + if ( isset( $this->rcResults[$rcid] ) ) { + $class = $this->rcResults[$rcid] ? 'mw-abusefilter-changeslist-match' : 'mw-abusefilter-changeslist-nomatch'; @@ -158,4 +164,9 @@ class AbuseFilterChangesList extends OldChangesList { public function insertRollback( &$s, &$rc ) { // Kill rollback links. } + + public function setRCResult( RecentChange $rc, bool $matches ): void { + $id = $rc->getAttribute( 'rc_id' ); + $this->rcResults[$id] = $matches; + } } diff --git a/includes/View/AbuseFilterViewTestBatch.php b/includes/View/AbuseFilterViewTestBatch.php index 5e8a2c856..a414372b8 100644 --- a/includes/View/AbuseFilterViewTestBatch.php +++ b/includes/View/AbuseFilterViewTestBatch.php @@ -298,8 +298,7 @@ class AbuseFilterViewTestBatch extends AbuseFilterView { $result = $ruleChecker->checkConditions( $this->testPattern )->getResult(); if ( $result || $formData['ShowNegative'] ) { - // Stash result in RC item - $rc->filterResult = $result; + $changesList->setRCResult( $rc, $result ); $rc->counter = $counter++; $output .= $changesList->recentChangesLine( $rc, false ); }