2017-12-16 00:26:25 +00:00
|
|
|
<?php
|
|
|
|
|
2020-12-03 14:11:19 +00:00
|
|
|
namespace MediaWiki\Extension\AbuseFilter\Pager;
|
|
|
|
|
2020-12-07 13:56:16 +00:00
|
|
|
use HtmlArmor;
|
|
|
|
use IContextSource;
|
|
|
|
use Linker;
|
2020-08-07 21:48:47 +00:00
|
|
|
use MediaWiki\Cache\LinkBatchFactory;
|
2020-12-07 13:56:16 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\AbuseFilterPermissionManager;
|
2020-09-18 14:49:13 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\AbuseFilterServices;
|
2020-12-07 13:56:16 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\CentralDBNotAvailableException;
|
2021-01-01 17:28:36 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\Special\SpecialAbuseLog;
|
2020-12-07 13:56:16 +00:00
|
|
|
use MediaWiki\Linker\LinkRenderer;
|
|
|
|
use MediaWiki\Linker\LinkTarget;
|
2021-09-15 20:54:55 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2020-12-07 13:56:16 +00:00
|
|
|
use MediaWiki\Permissions\PermissionManager;
|
2020-12-03 14:11:19 +00:00
|
|
|
use ReverseChronologicalPager;
|
2020-12-07 13:56:16 +00:00
|
|
|
use Sanitizer;
|
|
|
|
use SpecialPage;
|
2020-12-03 14:11:19 +00:00
|
|
|
use stdClass;
|
2020-12-07 13:56:16 +00:00
|
|
|
use Title;
|
|
|
|
use WikiMap;
|
2018-04-29 17:52:45 +00:00
|
|
|
use Wikimedia\Rdbms\IResultWrapper;
|
2020-12-07 13:56:16 +00:00
|
|
|
use Xml;
|
2018-04-05 14:11:01 +00:00
|
|
|
|
2017-12-16 00:26:25 +00:00
|
|
|
class AbuseLogPager extends ReverseChronologicalPager {
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
2022-02-11 10:21:12 +00:00
|
|
|
private $conds;
|
2017-12-16 00:26:25 +00:00
|
|
|
|
2020-08-07 21:48:47 +00:00
|
|
|
/** @var LinkBatchFactory */
|
|
|
|
private $linkBatchFactory;
|
|
|
|
|
2020-12-07 13:56:16 +00:00
|
|
|
/** @var PermissionManager */
|
|
|
|
private $permissionManager;
|
|
|
|
|
|
|
|
/** @var AbuseFilterPermissionManager */
|
|
|
|
private $afPermissionManager;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
private $basePageName;
|
2018-03-11 14:30:33 +00:00
|
|
|
|
2018-10-16 19:58:22 +00:00
|
|
|
/**
|
|
|
|
* @var string[] Map of [ id => show|hide ], for entries that we're currently (un)hiding
|
|
|
|
*/
|
|
|
|
private $hideEntries;
|
|
|
|
|
2017-12-16 00:26:25 +00:00
|
|
|
/**
|
2020-12-07 13:56:16 +00:00
|
|
|
* @param IContextSource $context
|
|
|
|
* @param LinkRenderer $linkRenderer
|
2017-12-16 00:26:25 +00:00
|
|
|
* @param array $conds
|
2020-08-07 21:48:47 +00:00
|
|
|
* @param LinkBatchFactory $linkBatchFactory
|
2020-12-07 13:56:16 +00:00
|
|
|
* @param PermissionManager $permManager
|
|
|
|
* @param AbuseFilterPermissionManager $afPermissionManager
|
|
|
|
* @param string $basePageName
|
2018-10-16 19:58:22 +00:00
|
|
|
* @param string[] $hideEntries
|
2017-12-16 00:26:25 +00:00
|
|
|
*/
|
2018-03-11 14:30:33 +00:00
|
|
|
public function __construct(
|
2020-12-07 13:56:16 +00:00
|
|
|
IContextSource $context,
|
|
|
|
LinkRenderer $linkRenderer,
|
2018-03-11 14:30:33 +00:00
|
|
|
array $conds,
|
|
|
|
LinkBatchFactory $linkBatchFactory,
|
2020-12-07 13:56:16 +00:00
|
|
|
PermissionManager $permManager,
|
|
|
|
AbuseFilterPermissionManager $afPermissionManager,
|
2018-10-16 19:58:22 +00:00
|
|
|
string $basePageName,
|
|
|
|
array $hideEntries = []
|
2018-03-11 14:30:33 +00:00
|
|
|
) {
|
2020-12-07 13:56:16 +00:00
|
|
|
parent::__construct( $context, $linkRenderer );
|
2022-02-11 10:21:12 +00:00
|
|
|
$this->conds = $conds;
|
2020-08-07 21:48:47 +00:00
|
|
|
$this->linkBatchFactory = $linkBatchFactory;
|
2020-12-07 13:56:16 +00:00
|
|
|
$this->permissionManager = $permManager;
|
|
|
|
$this->afPermissionManager = $afPermissionManager;
|
|
|
|
$this->basePageName = $basePageName;
|
2018-10-16 19:58:22 +00:00
|
|
|
$this->hideEntries = $hideEntries;
|
2017-12-16 00:26:25 +00:00
|
|
|
}
|
|
|
|
|
2018-04-04 21:14:25 +00:00
|
|
|
/**
|
2020-10-29 00:44:48 +00:00
|
|
|
* @param stdClass $row
|
2018-04-04 21:14:25 +00:00
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function formatRow( $row ) {
|
2020-12-07 13:56:16 +00:00
|
|
|
return $this->doFormatRow( $row );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param stdClass $row
|
|
|
|
* @param bool $isListItem
|
|
|
|
* @return string
|
|
|
|
*/
|
2021-07-21 18:51:12 +00:00
|
|
|
public function doFormatRow( stdClass $row, bool $isListItem = true ): string {
|
2022-07-02 13:35:00 +00:00
|
|
|
$performer = $this->getAuthority();
|
|
|
|
$visibility = SpecialAbuseLog::getEntryVisibilityForUser( $row, $performer, $this->afPermissionManager );
|
2020-12-07 13:56:16 +00:00
|
|
|
|
2021-09-15 18:23:36 +00:00
|
|
|
if ( $visibility !== SpecialAbuseLog::VISIBILITY_VISIBLE ) {
|
2020-12-07 13:56:16 +00:00
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
$linkRenderer = $this->getLinkRenderer();
|
2022-06-28 18:33:46 +00:00
|
|
|
$diffLink = false;
|
2020-12-07 13:56:16 +00:00
|
|
|
|
|
|
|
if ( !$row->afl_wiki ) {
|
2022-06-28 18:33:46 +00:00
|
|
|
$title = Title::makeTitle( $row->afl_namespace, $row->afl_title );
|
|
|
|
|
2020-12-07 13:56:16 +00:00
|
|
|
$pageLink = $linkRenderer->makeLink(
|
|
|
|
$title,
|
|
|
|
null,
|
|
|
|
[],
|
|
|
|
[ 'redirect' => 'no' ]
|
|
|
|
);
|
|
|
|
if ( $row->rev_id ) {
|
|
|
|
$diffLink = $linkRenderer->makeKnownLink(
|
|
|
|
$title,
|
|
|
|
new HtmlArmor( $this->msg( 'abusefilter-log-diff' )->parse() ),
|
|
|
|
[],
|
|
|
|
[ 'diff' => 'prev', 'oldid' => $row->rev_id ]
|
|
|
|
);
|
|
|
|
} elseif (
|
|
|
|
isset( $row->ar_timestamp ) && $row->ar_timestamp
|
|
|
|
&& $this->canSeeUndeleteDiffForPage( $title )
|
|
|
|
) {
|
|
|
|
$diffLink = $linkRenderer->makeKnownLink(
|
|
|
|
SpecialPage::getTitleFor( 'Undelete' ),
|
|
|
|
new HtmlArmor( $this->msg( 'abusefilter-log-diff' )->parse() ),
|
|
|
|
[],
|
|
|
|
[
|
|
|
|
'diff' => 'prev',
|
|
|
|
'target' => $title->getPrefixedText(),
|
|
|
|
'timestamp' => $row->ar_timestamp,
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$pageLink = WikiMap::makeForeignLink( $row->afl_wiki, $row->afl_title );
|
|
|
|
|
|
|
|
if ( $row->afl_rev_id ) {
|
|
|
|
$diffUrl = WikiMap::getForeignURL( $row->afl_wiki, $row->afl_title );
|
|
|
|
$diffUrl = wfAppendQuery( $diffUrl,
|
|
|
|
[ 'diff' => 'prev', 'oldid' => $row->afl_rev_id ] );
|
|
|
|
|
|
|
|
$diffLink = Linker::makeExternalLink( $diffUrl,
|
|
|
|
$this->msg( 'abusefilter-log-diff' )->text() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !$row->afl_wiki ) {
|
|
|
|
// Local user
|
|
|
|
$userLink = SpecialAbuseLog::getUserLinks( $row->afl_user, $row->afl_user_text );
|
|
|
|
} else {
|
2021-09-16 17:16:28 +00:00
|
|
|
$userLink = WikiMap::foreignUserLink( $row->afl_wiki, $row->afl_user_text ) . ' ' .
|
|
|
|
$this->msg( 'parentheses' )->params( WikiMap::getWikiName( $row->afl_wiki ) )->escaped();
|
2020-12-07 13:56:16 +00:00
|
|
|
}
|
|
|
|
|
2022-06-28 18:33:46 +00:00
|
|
|
$lang = $this->getLanguage();
|
2021-03-08 23:54:03 +00:00
|
|
|
$timestamp = htmlspecialchars( $lang->userTimeAndDate( $row->afl_timestamp, $this->getUser() ) );
|
2020-12-07 13:56:16 +00:00
|
|
|
|
|
|
|
$actions_takenRaw = $row->afl_actions;
|
|
|
|
if ( !strlen( trim( $actions_takenRaw ) ) ) {
|
|
|
|
$actions_taken = $this->msg( 'abusefilter-log-noactions' )->escaped();
|
|
|
|
} else {
|
|
|
|
$actions = explode( ',', $actions_takenRaw );
|
|
|
|
$displayActions = [];
|
|
|
|
|
2020-10-02 15:08:48 +00:00
|
|
|
$specsFormatter = AbuseFilterServices::getSpecsFormatter();
|
|
|
|
$specsFormatter->setMessageLocalizer( $this->getContext() );
|
2020-12-07 13:56:16 +00:00
|
|
|
foreach ( $actions as $action ) {
|
2020-10-02 15:08:48 +00:00
|
|
|
$displayActions[] = $specsFormatter->getActionDisplay( $action );
|
2020-12-07 13:56:16 +00:00
|
|
|
}
|
|
|
|
$actions_taken = $lang->commaList( $displayActions );
|
|
|
|
}
|
|
|
|
|
2019-02-06 16:07:01 +00:00
|
|
|
$filterID = $row->afl_filter_id;
|
|
|
|
$global = $row->afl_global;
|
2020-12-07 13:56:16 +00:00
|
|
|
|
|
|
|
if ( $global ) {
|
|
|
|
// Pull global filter description
|
|
|
|
$lookup = AbuseFilterServices::getFilterLookup();
|
|
|
|
try {
|
|
|
|
$filterObj = $lookup->getFilter( $filterID, true );
|
|
|
|
$globalDesc = $filterObj->getName();
|
|
|
|
$escaped_comments = Sanitizer::escapeHtmlAllowEntities( $globalDesc );
|
|
|
|
$filter_hidden = $filterObj->isHidden();
|
|
|
|
} catch ( CentralDBNotAvailableException $_ ) {
|
|
|
|
$escaped_comments = $this->msg( 'abusefilter-log-description-not-available' )->escaped();
|
|
|
|
// either hide all filters, including not hidden, or show all, including hidden
|
|
|
|
// we choose the former
|
|
|
|
$filter_hidden = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$escaped_comments = Sanitizer::escapeHtmlAllowEntities(
|
|
|
|
$row->af_public_comments );
|
|
|
|
$filter_hidden = $row->af_hidden;
|
|
|
|
}
|
|
|
|
|
2022-07-02 13:35:00 +00:00
|
|
|
if ( $this->afPermissionManager->canSeeLogDetailsForFilter( $performer, $filter_hidden ) ) {
|
2020-12-07 13:56:16 +00:00
|
|
|
$actionLinks = [];
|
|
|
|
|
|
|
|
if ( $isListItem ) {
|
|
|
|
$detailsLink = $linkRenderer->makeKnownLink(
|
|
|
|
SpecialPage::getTitleFor( $this->basePageName, $row->afl_id ),
|
|
|
|
$this->msg( 'abusefilter-log-detailslink' )->text()
|
|
|
|
);
|
|
|
|
$actionLinks[] = $detailsLink;
|
|
|
|
}
|
|
|
|
|
|
|
|
$examineTitle = SpecialPage::getTitleFor( 'AbuseFilter', 'examine/log/' . $row->afl_id );
|
|
|
|
$examineLink = $linkRenderer->makeKnownLink(
|
|
|
|
$examineTitle,
|
|
|
|
new HtmlArmor( $this->msg( 'abusefilter-changeslist-examine' )->parse() )
|
|
|
|
);
|
|
|
|
$actionLinks[] = $examineLink;
|
|
|
|
|
|
|
|
if ( $diffLink ) {
|
|
|
|
$actionLinks[] = $diffLink;
|
|
|
|
}
|
|
|
|
|
2022-07-02 13:35:00 +00:00
|
|
|
if ( !$isListItem && $this->afPermissionManager->canHideAbuseLog( $performer ) ) {
|
2021-01-11 11:29:10 +00:00
|
|
|
// Link for hiding a single entry from the details view
|
|
|
|
$hideLink = $linkRenderer->makeKnownLink(
|
|
|
|
SpecialPage::getTitleFor( $this->basePageName, 'hide' ),
|
|
|
|
$this->msg( 'abusefilter-log-hidelink' )->text(),
|
|
|
|
[],
|
|
|
|
[ "hideids[$row->afl_id]" => 1 ]
|
|
|
|
);
|
|
|
|
|
|
|
|
$actionLinks[] = $hideLink;
|
|
|
|
}
|
|
|
|
|
2020-12-07 13:56:16 +00:00
|
|
|
if ( $global ) {
|
|
|
|
$centralDb = $this->getConfig()->get( 'AbuseFilterCentralDB' );
|
|
|
|
$linkMsg = $this->msg( 'abusefilter-log-detailedentry-global' )
|
|
|
|
->numParams( $filterID );
|
|
|
|
if ( $centralDb !== null ) {
|
|
|
|
$globalURL = WikiMap::getForeignURL(
|
|
|
|
$centralDb,
|
|
|
|
'Special:AbuseFilter/' . $filterID
|
|
|
|
);
|
|
|
|
$filterLink = Linker::makeExternalLink( $globalURL, $linkMsg->text() );
|
|
|
|
} else {
|
|
|
|
$filterLink = $linkMsg->escaped();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$title = SpecialPage::getTitleFor( 'AbuseFilter', (string)$filterID );
|
|
|
|
$linkText = $this->msg( 'abusefilter-log-detailedentry-local' )
|
|
|
|
->numParams( $filterID )->text();
|
|
|
|
$filterLink = $linkRenderer->makeKnownLink( $title, $linkText );
|
|
|
|
}
|
|
|
|
$description = $this->msg( 'abusefilter-log-detailedentry-meta' )->rawParams(
|
|
|
|
$timestamp,
|
|
|
|
$userLink,
|
|
|
|
$filterLink,
|
|
|
|
htmlspecialchars( $row->afl_action ),
|
|
|
|
$pageLink,
|
|
|
|
$actions_taken,
|
|
|
|
$escaped_comments,
|
|
|
|
$lang->pipeList( $actionLinks )
|
|
|
|
)->params( $row->afl_user_text )->parse();
|
|
|
|
} else {
|
|
|
|
if ( $diffLink ) {
|
|
|
|
$msg = 'abusefilter-log-entry-withdiff';
|
|
|
|
} else {
|
|
|
|
$msg = 'abusefilter-log-entry';
|
|
|
|
}
|
|
|
|
$description = $this->msg( $msg )->rawParams(
|
|
|
|
$timestamp,
|
|
|
|
$userLink,
|
|
|
|
htmlspecialchars( $row->afl_action ),
|
|
|
|
$pageLink,
|
|
|
|
$actions_taken,
|
|
|
|
$escaped_comments,
|
|
|
|
// Passing $7 to 'abusefilter-log-entry' will do nothing, as it's not used.
|
|
|
|
$diffLink
|
|
|
|
)->params( $row->afl_user_text )->parse();
|
|
|
|
}
|
|
|
|
|
|
|
|
$attribs = null;
|
2018-10-16 19:58:22 +00:00
|
|
|
if (
|
|
|
|
$this->isHidingEntry( $row ) === true ||
|
|
|
|
// If isHidingEntry is false, we've just unhidden the row
|
2021-09-15 20:54:55 +00:00
|
|
|
( $this->isHidingEntry( $row ) === null && $row->afl_deleted )
|
2018-10-16 19:58:22 +00:00
|
|
|
) {
|
2020-12-07 13:56:16 +00:00
|
|
|
$attribs = [ 'class' => 'mw-abusefilter-log-hidden-entry' ];
|
2018-10-16 19:58:22 +00:00
|
|
|
}
|
2021-09-15 20:54:55 +00:00
|
|
|
if ( self::entryHasAssociatedDeletedRev( $row ) ) {
|
2020-12-07 13:56:16 +00:00
|
|
|
$description .= ' ' .
|
|
|
|
$this->msg( 'abusefilter-log-hidden-implicit' )->parse();
|
|
|
|
}
|
|
|
|
|
2022-07-02 13:35:00 +00:00
|
|
|
if ( $isListItem && !$this->hideEntries && $this->afPermissionManager->canHideAbuseLog( $performer ) ) {
|
2021-01-11 11:29:10 +00:00
|
|
|
// Checkbox for hiding multiple entries, single entries are handled above
|
2022-07-07 14:51:34 +00:00
|
|
|
$description = Xml::check( 'hideids[' . $row->afl_id . ']' ) . ' ' . $description;
|
2018-10-16 19:58:22 +00:00
|
|
|
}
|
|
|
|
|
2020-12-07 13:56:16 +00:00
|
|
|
if ( $isListItem ) {
|
|
|
|
return Xml::tags( 'li', $attribs, $description );
|
|
|
|
} else {
|
|
|
|
return Xml::tags( 'span', $attribs, $description );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Can this user see diffs generated by Special:Undelete for the page?
|
|
|
|
* @see \SpecialUndelete
|
|
|
|
* @param LinkTarget $page
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
2021-07-21 18:51:12 +00:00
|
|
|
private function canSeeUndeleteDiffForPage( LinkTarget $page ): bool {
|
2020-12-07 13:56:16 +00:00
|
|
|
if ( !$this->canSeeUndeleteDiffs() ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ( [ 'deletedtext', 'undelete' ] as $action ) {
|
|
|
|
if ( $this->permissionManager->userCan(
|
|
|
|
$action, $this->getUser(), $page, PermissionManager::RIGOR_QUICK
|
|
|
|
) ) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Can this user see diffs generated by Special:Undelete?
|
|
|
|
* @see \SpecialUndelete
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
2021-07-21 18:51:12 +00:00
|
|
|
private function canSeeUndeleteDiffs(): bool {
|
2020-12-07 13:56:16 +00:00
|
|
|
if ( !$this->permissionManager->userHasRight( $this->getUser(), 'deletedhistory' ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->permissionManager->userHasAnyRight(
|
|
|
|
$this->getUser(), 'deletedtext', 'undelete' );
|
2017-12-16 00:26:25 +00:00
|
|
|
}
|
|
|
|
|
2018-04-04 21:14:25 +00:00
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getQueryInfo() {
|
2017-12-16 00:26:25 +00:00
|
|
|
$info = [
|
2020-09-16 20:17:12 +00:00
|
|
|
'tables' => [ 'abuse_filter_log', 'abuse_filter', 'revision' ],
|
|
|
|
'fields' => [
|
|
|
|
$this->mDb->tableName( 'abuse_filter_log' ) . '.*',
|
|
|
|
$this->mDb->tableName( 'abuse_filter' ) . '.*',
|
|
|
|
'rev_id',
|
|
|
|
],
|
2022-02-11 10:21:12 +00:00
|
|
|
'conds' => $this->conds,
|
2020-09-16 20:17:12 +00:00
|
|
|
'join_conds' => [
|
|
|
|
'abuse_filter' => [
|
|
|
|
'LEFT JOIN',
|
2019-02-06 16:07:01 +00:00
|
|
|
[ 'af_id=afl_filter_id', 'afl_global' => 0 ],
|
2020-09-16 20:17:12 +00:00
|
|
|
],
|
|
|
|
'revision' => [
|
|
|
|
'LEFT JOIN',
|
2017-12-16 00:26:25 +00:00
|
|
|
[
|
2020-09-16 20:17:12 +00:00
|
|
|
'afl_wiki IS NULL',
|
|
|
|
'afl_rev_id IS NOT NULL',
|
|
|
|
'rev_id=afl_rev_id',
|
|
|
|
]
|
2017-12-16 00:26:25 +00:00
|
|
|
],
|
2020-09-16 20:17:12 +00:00
|
|
|
],
|
2017-12-16 00:26:25 +00:00
|
|
|
];
|
|
|
|
|
2020-12-07 13:56:16 +00:00
|
|
|
if ( $this->canSeeUndeleteDiffs() ) {
|
2018-03-11 14:30:33 +00:00
|
|
|
$info['tables'][] = 'archive';
|
|
|
|
$info['fields'][] = 'ar_timestamp';
|
|
|
|
$info['join_conds']['archive'] = [
|
|
|
|
'LEFT JOIN',
|
|
|
|
[
|
|
|
|
'afl_wiki IS NULL',
|
|
|
|
'afl_rev_id IS NOT NULL',
|
|
|
|
'rev_id IS NULL',
|
|
|
|
'ar_rev_id=afl_rev_id',
|
|
|
|
]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2022-07-02 13:35:00 +00:00
|
|
|
if ( !$this->afPermissionManager->canSeeHiddenLogEntries( $this->getAuthority() ) ) {
|
2019-02-09 10:17:09 +00:00
|
|
|
$info['conds']['afl_deleted'] = 0;
|
2017-12-16 00:26:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return $info;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-04-29 17:52:45 +00:00
|
|
|
* @param IResultWrapper $result
|
2017-12-16 00:26:25 +00:00
|
|
|
*/
|
|
|
|
protected function preprocessResults( $result ) {
|
|
|
|
if ( $this->getNumRows() === 0 ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-08-07 21:48:47 +00:00
|
|
|
$lb = $this->linkBatchFactory->newLinkBatch();
|
2017-12-16 00:26:25 +00:00
|
|
|
$lb->setCaller( __METHOD__ );
|
|
|
|
foreach ( $result as $row ) {
|
|
|
|
// Only for local wiki results
|
|
|
|
if ( !$row->afl_wiki ) {
|
|
|
|
$lb->add( $row->afl_namespace, $row->afl_title );
|
2022-06-28 18:37:41 +00:00
|
|
|
$lb->add( NS_USER, $row->afl_user_text );
|
2017-12-16 00:26:25 +00:00
|
|
|
$lb->add( NS_USER_TALK, $row->afl_user_text );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$lb->execute();
|
|
|
|
$result->seek( 0 );
|
|
|
|
}
|
|
|
|
|
2021-09-15 20:54:55 +00:00
|
|
|
/**
|
|
|
|
* @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;
|
|
|
|
}
|
|
|
|
|
2018-10-16 19:58:22 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
* when we decide whether to display the entry as hidden the DB hasn't been updated yet.
|
|
|
|
*
|
|
|
|
* @param stdClass $row
|
|
|
|
* @return bool|null True if just hidden, false if just unhidden, null if untouched
|
|
|
|
*/
|
2021-07-21 18:51:12 +00:00
|
|
|
private function isHidingEntry( stdClass $row ): ?bool {
|
2018-10-16 19:58:22 +00:00
|
|
|
if ( isset( $this->hideEntries[ $row->afl_id ] ) ) {
|
|
|
|
return $this->hideEntries[ $row->afl_id ] === 'hide';
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2018-04-04 21:14:25 +00:00
|
|
|
/**
|
2021-01-17 11:54:43 +00:00
|
|
|
* @codeCoverageIgnore Merely declarative
|
|
|
|
* @inheritDoc
|
2018-04-04 21:14:25 +00:00
|
|
|
*/
|
|
|
|
public function getIndexField() {
|
2017-12-16 00:26:25 +00:00
|
|
|
return 'afl_timestamp';
|
|
|
|
}
|
|
|
|
}
|