- public $useDiff, $pageBlobClass, $orphanBlobClass;
+ public $numBatches = 0;
+ public $pageBlobClass, $orphanBlobClass;
public $slavePipes, $slaveProcs, $prevSlaveId;
public $copyOnly = false;
public $isChild = false;
public $slavePipes, $slaveProcs, $prevSlaveId;
public $copyOnly = false;
public $isChild = false;
'debug-log' => 'debugLog',
'info-log' => 'infoLog',
'critical-log' => 'criticalLog',
'debug-log' => 'debugLog',
'info-log' => 'infoLog',
'critical-log' => 'criticalLog',
static function getOptionsWithArgs() {
return self::$optionsWithArgs;
}
static function newFromCommandLine( $args, $options ) {
static function getOptionsWithArgs() {
return self::$optionsWithArgs;
}
static function newFromCommandLine( $args, $options ) {
foreach ( self::$cmdLineOptionMap as $cmdOption => $classOption ) {
if ( isset( $options[$cmdOption] ) ) {
$jobOptions[$classOption] = $options[$cmdOption];
foreach ( self::$cmdLineOptionMap as $cmdOption => $classOption ) {
if ( isset( $options[$cmdOption] ) ) {
$jobOptions[$classOption] = $options[$cmdOption];
- $this->useDiff = function_exists( 'xdiff_string_bdiff' );
- $this->pageBlobClass = $this->useDiff ? 'DiffHistoryBlob' : 'ConcatenatedGzipHistoryBlob';
+ $this->pageBlobClass = function_exists( 'xdiff_string_bdiff' ) ?
+ 'DiffHistoryBlob' : 'ConcatenatedGzipHistoryBlob';
- $row = $dbr->selectRow( 'blob_tracking', '*', false, __METHOD__ );
+ $row = $dbr->selectRow( 'blob_tracking', '*', '', __METHOD__ );
' --wiki ' . wfEscapeShellArg( wfWikiID() ) .
' ' . call_user_func_array( 'wfEscapeShellArg', $this->destClusters );
' --wiki ' . wfEscapeShellArg( wfWikiID() ) .
' ' . call_user_func_array( 'wfEscapeShellArg', $this->destClusters );
- $pipes = false;
- $spec = array(
- array( 'pipe', 'r' ),
- array( 'file', 'php://stdout', 'w' ),
- array( 'file', 'php://stderr', 'w' )
- );
+ $pipes = [];
+ $spec = [
+ [ 'pipe', 'r' ],
+ [ 'file', 'php://stdout', 'w' ],
+ [ 'file', 'php://stderr', 'w' ]
+ ];
MediaWiki\suppressWarnings();
$proc = proc_open( "$cmd --slave-id $i", $spec, $pipes );
MediaWiki\restoreWarnings();
MediaWiki\suppressWarnings();
$proc = proc_open( "$cmd --slave-id $i", $spec, $pipes );
MediaWiki\restoreWarnings();
- $numPipes = stream_select( $x = array(), $pipes, $y = array(), 3600 );
+ $numPipes = stream_select( $x = [], $pipes, $y = [], 3600 );
$numPages = $dbr->selectField( 'blob_tracking',
'COUNT(DISTINCT bt_page)',
# A condition is required so that this query uses the index
$numPages = $dbr->selectField( 'blob_tracking',
'COUNT(DISTINCT bt_page)',
# A condition is required so that this query uses the index
$this->report( 'pages', $i, $numPages );
}
$this->report( 'pages', $i, $numPages );
$this->report( 'pages', $i, $numPages );
}
$this->report( 'pages', $i, $numPages );
} else {
$numOrphans = $dbr->selectField( 'blob_tracking',
'COUNT(DISTINCT bt_text_id)',
} else {
$numOrphans = $dbr->selectField( 'blob_tracking',
'COUNT(DISTINCT bt_text_id)',
'DISTINCT',
'ORDER BY' => 'bt_text_id',
'LIMIT' => $this->batchSize
'DISTINCT',
'ORDER BY' => 'bt_text_id',
'LIMIT' => $this->batchSize
$args = array_slice( $ids, 0, $this->orphanBatchSize );
$ids = array_slice( $ids, $this->orphanBatchSize );
array_unshift( $args, 'doOrphanList' );
$args = array_slice( $ids, 0, $this->orphanBatchSize );
$ids = array_slice( $ids, $this->orphanBatchSize );
array_unshift( $args, 'doOrphanList' );
$this->report( 'orphans', $i, $numOrphans );
}
$this->report( 'orphans', $i, $numOrphans );
$this->report( 'orphans', $i, $numOrphans );
}
$this->report( 'orphans', $i, $numOrphans );
'ORDER BY' => 'bt_text_id',
'LIMIT' => $this->batchSize
'ORDER BY' => 'bt_text_id',
'LIMIT' => $this->batchSize
'ORDER BY' => 'bt_text_id',
'LIMIT' => $this->batchSize,
'ORDER BY' => 'bt_text_id',
'LIMIT' => $this->batchSize,
);
if ( !$res->numRows() ) {
break;
}
$this->debug( 'Incomplete: ' . $res->numRows() . ' rows' );
foreach ( $res as $row ) {
);
if ( !$res->numRows() ) {
break;
}
$this->debug( 'Incomplete: ' . $res->numRows() . ' rows' );
foreach ( $res as $row ) {
$this->moveTextRow( $row->bt_text_id, $row->bt_new_url );
if ( $row->bt_text_id % 10 == 0 ) {
wfWaitForSlaves();
}
}
$this->moveTextRow( $row->bt_text_id, $row->bt_new_url );
if ( $row->bt_text_id % 10 == 0 ) {
wfWaitForSlaves();
}
}
function doOrphanList( $textIds ) {
// Finish incomplete moves
if ( !$this->copyOnly ) {
function doOrphanList( $textIds ) {
// Finish incomplete moves
if ( !$this->copyOnly ) {
$this->syncDBs();
}
$trx = new CgzCopyTransaction( $this, $this->orphanBlobClass );
$res = wfGetDB( DB_SLAVE )->select(
$this->syncDBs();
}
$trx = new CgzCopyTransaction( $this, $this->orphanBlobClass );
$res = wfGetDB( DB_SLAVE )->select(
- array( 'text', 'blob_tracking' ),
- array( 'old_id', 'old_text', 'old_flags' ),
- array(
+ [ 'text', 'blob_tracking' ],
+ [ 'old_id', 'old_text', 'old_flags' ],
+ [
function __construct( $parent, $blobClass ) {
$this->blobClass = $blobClass;
$this->cgz = false;
function __construct( $parent, $blobClass ) {
$this->blobClass = $blobClass;
$this->cgz = false;
foreach ( $this->texts as $textId => $text ) {
$hash = $this->cgz->addItem( $text );
$this->referrers[$textId] = $hash;
foreach ( $this->texts as $textId => $text ) {
$hash = $this->cgz->addItem( $text );
$this->referrers[$textId] = $hash;
$dbw = wfGetDB( DB_MASTER );
$dbw->begin( __METHOD__ );
$res = $dbw->select( 'blob_tracking',
$dbw = wfGetDB( DB_MASTER );
$dbw->begin( __METHOD__ );
$res = $dbw->select( 'blob_tracking',
- array( 'bt_text_id', 'bt_moved' ),
- array( 'bt_text_id' => array_keys( $this->referrers ) ),
- __METHOD__, array( 'FOR UPDATE' ) );
+ [ 'bt_text_id', 'bt_moved' ],
+ [ 'bt_text_id' => array_keys( $this->referrers ) ],
+ __METHOD__, [ 'FOR UPDATE' ] );
// All have been moved already
if ( $originalCount > 1 ) {
// This is suspcious, make noise
// All have been moved already
if ( $originalCount > 1 ) {
// This is suspcious, make noise
foreach ( $this->referrers as $textId => $hash ) {
$url = $baseUrl . '/' . $hash;
$dbw->update( 'blob_tracking',
foreach ( $this->referrers as $textId => $hash ) {
$url = $baseUrl . '/' . $hash;
$dbw->update( 'blob_tracking',