Remove SpecialAbuseLog::isHidden

This is a breaking change for the API: 'hidden' is now either true or
false, depending on afl_deleted. 'implicit' is no longer a possible
value, the caller should compute it instead if necessary.

Then simplify the remaining usage of isHidden, using a temporary private
method.

Bug: T291718
Change-Id: I97b5195d306c35ddca3f071d9ff4d896f9fd5c8d
This commit is contained in:
Daimona Eaytoy 2021-09-15 22:54:55 +02:00 committed by Krinkle
parent 4055aa0b01
commit 773d553c8e
3 changed files with 20 additions and 33 deletions

View file

@ -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 ) {

View file

@ -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

View file

@ -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