* @ingroup Maintenance
*/
+use MediaWiki\MediaWikiServices;
+use MediaWiki\Storage\RevisionRecord;
use Wikimedia\Rdbms\IDatabase;
require_once __DIR__ . '/Maintenance.php';
if ( ( $category = $this->getOption( 'category', false ) ) !== false ) {
$title = Title::makeTitleSafe( NS_CATEGORY, $category );
if ( !$title ) {
- $this->error( "'$category' is an invalid category name!\n", true );
+ $this->fatalError( "'$category' is an invalid category name!\n" );
}
$this->refreshCategory( $title );
} elseif ( ( $category = $this->getOption( 'tracking-category', false ) ) !== false ) {
$redir = $this->hasOption( 'redirects-only' );
$oldRedir = $this->hasOption( 'old-redirects-only' );
$this->doRefreshLinks( $start, $new, $end, $redir, $oldRedir );
- $this->deleteLinksFromNonexistent( null, null, $this->mBatchSize, $dfnChunkSize );
+ $this->deleteLinksFromNonexistent( null, null, $this->getBatchSize(), $dfnChunkSize );
} else {
- $this->deleteLinksFromNonexistent( $start, $end, $this->mBatchSize, $dfnChunkSize );
+ $this->deleteLinksFromNonexistent( $start, $end, $this->getBatchSize(), $dfnChunkSize );
}
}
}
} else {
if ( !$end ) {
- $maxPage = $dbr->selectField( 'page', 'max(page_id)', false );
- $maxRD = $dbr->selectField( 'redirect', 'max(rd_from)', false );
+ $maxPage = $dbr->selectField( 'page', 'max(page_id)', '', __METHOD__ );
+ $maxRD = $dbr->selectField( 'redirect', 'max(rd_from)', '', __METHOD__ );
$end = max( $maxPage, $maxRD );
}
$this->output( "Refreshing redirects table.\n" );
}
$rt = null;
- $content = $page->getContent( Revision::RAW );
+ $content = $page->getContent( RevisionRecord::RAW );
if ( $content !== null ) {
$rt = $content->getUltimateRedirectTarget();
}
public static function fixLinksFromArticle( $id, $ns = false ) {
$page = WikiPage::newFromID( $id );
- LinkCache::singleton()->clear();
+ MediaWikiServices::getInstance()->getLinkCache()->clear();
if ( $page === null ) {
return;
return;
}
- $content = $page->getContent( Revision::RAW );
- if ( $content === null ) {
- return;
- }
-
- $updates = $content->getSecondaryDataUpdates(
- $page->getTitle(), /* $old = */ null, /* $recursive = */ false );
- foreach ( $updates as $update ) {
- DeferredUpdates::addUpdate( $update );
- DeferredUpdates::doUpdates();
- }
+ // Defer updates to post-send but then immediately execute deferred updates;
+ // this is the simplest way to run all updates immediately (including updates
+ // scheduled by other updates).
+ $page->doSecondaryDataUpdates( [
+ 'defer' => DeferredUpdates::POSTSEND,
+ 'recursive' => false,
+ ] );
+ DeferredUpdates::doUpdates();
}
/**
do {
$finalConds = $conds;
$timestamp = $dbr->addQuotes( $timestamp );
- $finalConds []=
+ $finalConds [] =
"(cl_timestamp > $timestamp OR (cl_timestamp = $timestamp AND cl_from > $lastId))";
$res = $dbr->select( [ 'page', 'categorylinks' ],
[ 'page_id', 'cl_timestamp' ],
__METHOD__,
[
'ORDER BY' => [ 'cl_timestamp', 'cl_from' ],
- 'LIMIT' => $this->mBatchSize,
+ 'LIMIT' => $this->getBatchSize(),
]
);
self::fixLinksFromArticle( $row->page_id );
}
- } while ( $res->numRows() == $this->mBatchSize );
+ } while ( $res->numRows() == $this->getBatchSize() );
}
/**
if ( isset( $cats[$categoryKey] ) ) {
return $cats[$categoryKey]['cats'];
}
- $this->error( "Unknown tracking category {$categoryKey}\n", true );
+ $this->fatalError( "Unknown tracking category {$categoryKey}\n" );
}
}
-$maintClass = 'RefreshLinks';
+$maintClass = RefreshLinks::class;
require_once RUN_MAINTENANCE_IF_MAIN;