( $this->hasOption( 'from' ) && !$this->hasOption( 'to' ) ) ||
( !$this->hasOption( 'from' ) && $this->hasOption( 'to' ) )
) {
- $this->error( "Both 'from' and 'to' must be given, or neither", 1 );
+ $this->fatalError( "Both 'from' and 'to' must be given, or neither" );
}
$this->rebuildRecentChangesTablePass1();
*/
private function rebuildRecentChangesTablePass1() {
$dbw = $this->getDB( DB_MASTER );
- $revCommentStore = new CommentStore( 'rev_comment' );
- $rcCommentStore = new CommentStore( 'rc_comment' );
+ $commentStore = CommentStore::getStore();
if ( $this->hasOption( 'from' ) && $this->hasOption( 'to' ) ) {
$this->cutoffFrom = wfTimestamp( TS_UNIX, $this->getOption( 'from' ) );
'rc_timestamp < ' . $dbw->addQuotes( $dbw->timestamp( $this->cutoffTo ) )
]
);
- foreach ( array_chunk( $rcids, $this->mBatchSize ) as $rcidBatch ) {
+ foreach ( array_chunk( $rcids, $this->getBatchSize() ) as $rcidBatch ) {
$dbw->delete( 'recentchanges', [ 'rc_id' => $rcidBatch ], __METHOD__ );
wfGetLBFactory()->waitForReplication();
}
$this->output( "Loading from page and revision tables...\n" );
- $commentQuery = $revCommentStore->getJoin();
+ $commentQuery = $commentStore->getJoin( 'rev_comment' );
$res = $dbw->select(
[ 'revision', 'page' ] + $commentQuery['tables'],
[
$this->output( "Inserting from page and revision tables...\n" );
$inserted = 0;
foreach ( $res as $row ) {
- $comment = $revCommentStore->getComment( $row );
+ $comment = $commentStore->getComment( 'rev_comment', $row );
$dbw->insert(
'recentchanges',
[
'rc_type' => $row->page_is_new ? RC_NEW : RC_EDIT,
'rc_source' => $row->page_is_new ? RecentChange::SRC_NEW : RecentChange::SRC_EDIT,
'rc_deleted' => $row->rev_deleted
- ] + $rcCommentStore->insert( $dbw, $comment ),
+ ] + $commentStore->insert( $dbw, 'rc_comment', $comment ),
__METHOD__
);
- if ( ( ++$inserted % $this->mBatchSize ) == 0 ) {
+ if ( ( ++$inserted % $this->getBatchSize() ) == 0 ) {
wfGetLBFactory()->waitForReplication();
}
}
$lastOldId = intval( $obj->rc_this_oldid );
$lastSize = $size;
- if ( ( ++$updated % $this->mBatchSize ) == 0 ) {
+ if ( ( ++$updated % $this->getBatchSize() ) == 0 ) {
wfGetLBFactory()->waitForReplication();
}
}
global $wgLogTypes, $wgLogRestrictions;
$dbw = $this->getDB( DB_MASTER );
- $logCommentStore = new CommentStore( 'log_comment' );
- $rcCommentStore = new CommentStore( 'rc_comment' );
+ $commentStore = CommentStore::getStore();
$this->output( "Loading from user, page, and logging tables...\n" );
- $commentQuery = $logCommentStore->getJoin();
+ $commentQuery = $commentStore->getJoin( 'log_comment' );
$res = $dbw->select(
[ 'user', 'logging', 'page' ] + $commentQuery['tables'],
[
$inserted = 0;
foreach ( $res as $row ) {
- $comment = $logCommentStore->getComment( $row );
+ $comment = $commentStore->getComment( 'log_comment', $row );
$dbw->insert(
'recentchanges',
[
'rc_logid' => $row->log_id,
'rc_params' => $row->log_params,
'rc_deleted' => $row->log_deleted
- ] + $rcCommentStore->insert( $dbw, $comment ),
+ ] + $commentStore->insert( $dbw, 'rc_comment', $comment ),
__METHOD__
);
- if ( ( ++$inserted % $this->mBatchSize ) == 0 ) {
+ if ( ( ++$inserted % $this->getBatchSize() ) == 0 ) {
wfGetLBFactory()->waitForReplication();
}
}
__METHOD__
);
- foreach ( array_chunk( $rcids, $this->mBatchSize ) as $rcidBatch ) {
+ foreach ( array_chunk( $rcids, $this->getBatchSize() ) as $rcidBatch ) {
$dbw->update(
'recentchanges',
[ 'rc_bot' => 1 ],
__METHOD__
);
- if ( ( ++$updates % $this->mBatchSize ) == 0 ) {
+ if ( ( ++$updates % $this->getBatchSize() ) == 0 ) {
wfGetLBFactory()->waitForReplication();
}
}
}
}
-$maintClass = "RebuildRecentchanges";
+$maintClass = RebuildRecentchanges::class;
require_once RUN_MAINTENANCE_IF_MAIN;