*/
class FixBug20757 extends Maintenance {
public $batchSize = 10000;
- public $mapCache = array();
+ public $mapCache = [];
public $mapCacheSize = 0;
public $maxMapCacheSize = 1000000;
}
function execute() {
- $dbr = $this->getDB( DB_SLAVE );
+ $dbr = $this->getDB( DB_REPLICA );
$dbw = $this->getDB( DB_MASTER );
$dryRun = $this->getOption( 'dry-run' );
$totalRevs = $dbr->selectField( 'text', 'MAX(old_id)', false, __METHOD__ );
- if ( $dbr->getType() == 'mysql' ) {
- // In MySQL 4.1+, the binary field old_text has a non-working LOWER() function
- $lowerLeft = 'LOWER(CONVERT(LEFT(old_text,22) USING latin1))';
- }
+ // In MySQL 4.1+, the binary field old_text has a non-working LOWER() function
+ $lowerLeft = 'LOWER(CONVERT(LEFT(old_text,22) USING latin1))';
while ( true ) {
print "ID: $startId / $totalRevs\r";
$res = $dbr->select(
'text',
- array( 'old_id', 'old_flags', 'old_text' ),
- array(
+ [ 'old_id', 'old_flags', 'old_text' ],
+ [
'old_id > ' . intval( $startId ),
'old_flags LIKE \'%object%\' AND old_flags NOT LIKE \'%external%\'',
"$lowerLeft = 'o:15:\"historyblobstub\"'",
- ),
+ ],
__METHOD__,
- array(
+ [
'ORDER BY' => 'old_id',
'LIMIT' => $this->batchSize,
- )
+ ]
);
if ( !$res->numRows() ) {
break;
}
- $secondaryIds = array();
- $stubs = array();
+ $secondaryIds = [];
+ $stubs = [];
foreach ( $res as $row ) {
$startId = $row->old_id;
// Queue the stub for future batch processing
$id = intval( $obj->mOldId );
$secondaryIds[] = $id;
- $stubs[$row->old_id] = array(
+ $stubs[$row->old_id] = [
'legacyEncoding' => $legacyEncoding,
'secondaryId' => $id,
'hash' => $obj->mHash,
- );
+ ];
}
$secondaryIds = array_unique( $secondaryIds );
$res = $dbr->select(
'blob_tracking',
'*',
- array(
+ [
'bt_text_id' => $secondaryIds,
- ),
+ ],
__METHOD__
);
- $trackedBlobs = array();
+ $trackedBlobs = [];
foreach ( $res as $row ) {
$trackedBlobs[$row->bt_text_id] = $row;
}
// No tracked blob. Work out what went wrong
$secondaryRow = $dbr->selectRow(
'text',
- array( 'old_flags', 'old_text' ),
- array( 'old_id' => $secondaryId ),
+ [ 'old_flags', 'old_text' ],
+ [ 'old_id' => $secondaryId ],
__METHOD__
);
if ( !$secondaryRow ) {
$dbw->update(
'text',
// SET
- array(
+ [
'old_flags' => $newFlags,
'old_text' => $url
- ),
+ ],
// WHERE
- array( 'old_id' => $primaryId ),
+ [ 'old_id' => $primaryId ],
__METHOD__
);
// Add a blob_tracking row so that the new reference can be recompressed
// without needing to run trackBlobs.php again
$dbw->insert( 'blob_tracking',
- array(
+ [
'bt_page' => $pageId,
'bt_rev_id' => $revId,
'bt_text_id' => $primaryId,
'bt_cgz_hash' => $stub['hash'],
'bt_new_url' => null,
'bt_moved' => 0,
- ),
+ ],
__METHOD__
);
$this->commitTransaction( $dbw, __METHOD__ );
unset( $this->mapCache[$key] );
}
- $dbr = $this->getDB( DB_SLAVE );
- $map = array();
+ $dbr = $this->getDB( DB_REPLICA );
+ $map = [];
$res = $dbr->select( 'revision',
- array( 'rev_id', 'rev_text_id' ),
- array( 'rev_page' => $pageId ),
+ [ 'rev_id', 'rev_text_id' ],
+ [ 'rev_page' => $pageId ],
__METHOD__
);
foreach ( $res as $row ) {
if ( $path == "" ) {
return false;
}
- $text = ExternalStore::fetchFromUrl( $url );
+ $text = ExternalStore::fetchFromURL( $url );
}
if ( !in_array( 'object', $flags ) ) {
return false;