diff --git a/includes/Api/QueryAbuseLog.php b/includes/Api/QueryAbuseLog.php index d5c233c01..2d7a73e42 100644 --- a/includes/Api/QueryAbuseLog.php +++ b/includes/Api/QueryAbuseLog.php @@ -327,9 +327,8 @@ class QueryAbuseLog extends ApiQueryBase { } } - $hidden = SpecialAbuseLog::isHidden( $row ); - if ( $fld_hidden && $hidden ) { - $entry['hidden'] = $hidden; + if ( $fld_hidden ) { + $entry['hidden'] = (bool)$row->afl_deleted; } if ( $entry ) { diff --git a/includes/Pager/AbuseLogPager.php b/includes/Pager/AbuseLogPager.php index 820f30ccd..8cb9ae1fc 100644 --- a/includes/Pager/AbuseLogPager.php +++ b/includes/Pager/AbuseLogPager.php @@ -12,6 +12,7 @@ use MediaWiki\Extension\AbuseFilter\CentralDBNotAvailableException; use MediaWiki\Extension\AbuseFilter\Special\SpecialAbuseLog; use MediaWiki\Linker\LinkRenderer; use MediaWiki\Linker\LinkTarget; +use MediaWiki\MediaWikiServices; use MediaWiki\Permissions\PermissionManager; use ReverseChronologicalPager; use Sanitizer; @@ -274,15 +275,14 @@ class AbuseLogPager extends ReverseChronologicalPager { } $attribs = null; - $isHidden = SpecialAbuseLog::isHidden( $row ); if ( $this->isHidingEntry( $row ) === true || // If isHidingEntry is false, we've just unhidden the row - ( $this->isHidingEntry( $row ) === null && $isHidden === true ) + ( $this->isHidingEntry( $row ) === null && $row->afl_deleted ) ) { $attribs = [ 'class' => 'mw-abusefilter-log-hidden-entry' ]; } - if ( $isHidden === 'implicit' ) { + if ( self::entryHasAssociatedDeletedRev( $row ) ) { $description .= ' ' . $this->msg( 'abusefilter-log-hidden-implicit' )->parse(); } @@ -408,6 +408,21 @@ class AbuseLogPager extends ReverseChronologicalPager { $result->seek( 0 ); } + /** + * @param stdClass $row + * @return bool + * @todo This should be moved elsewhere + */ + private static function entryHasAssociatedDeletedRev( stdClass $row ): bool { + if ( !$row->afl_rev_id ) { + return false; + } + $revision = MediaWikiServices::getInstance() + ->getRevisionLookup() + ->getRevisionById( $row->afl_rev_id ); + return $revision && $revision->getVisibility() !== 0; + } + /** * Check whether the entry passed in is being currently hidden/unhidden. * This is used to format the entries list shown when updating visibility, and is necessary because diff --git a/includes/Special/SpecialAbuseLog.php b/includes/Special/SpecialAbuseLog.php index 34f84f01a..d237c18cf 100644 --- a/includes/Special/SpecialAbuseLog.php +++ b/includes/Special/SpecialAbuseLog.php @@ -1082,33 +1082,6 @@ class SpecialAbuseLog extends AbuseFilterSpecialPage { return $cache[$userName][$userId]; } - /** - * Given a log entry row, decides whether or not it can be viewed by the public. - * - * @param stdClass $row The abuse_filter_log row object. - * - * @return bool|string true if the item is explicitly hidden, false if it is not. - * The string 'implicit' if it is hidden because the corresponding revision is hidden. - * @todo Stop using this method. - */ - public static function isHidden( $row ) { - // First, check if the entry is hidden. Since this is an oversight-level deletion, - // it's more important than the associated revision being deleted. - if ( $row->afl_deleted ) { - return true; - } - if ( $row->afl_rev_id ) { - $revision = MediaWikiServices::getInstance() - ->getRevisionLookup() - ->getRevisionById( $row->afl_rev_id ); - if ( $revision && $revision->getVisibility() !== 0 ) { - return 'implicit'; - } - } - - return false; - } - /** * @param stdClass $row * @param Authority $authority