summaryrefslogtreecommitdiff
path: root/maintenance/storage/trackBlobs.php
diff options
context:
space:
mode:
Diffstat (limited to 'maintenance/storage/trackBlobs.php')
-rw-r--r--maintenance/storage/trackBlobs.php28
1 files changed, 20 insertions, 8 deletions
diff --git a/maintenance/storage/trackBlobs.php b/maintenance/storage/trackBlobs.php
index 0f25fb94..63327d53 100644
--- a/maintenance/storage/trackBlobs.php
+++ b/maintenance/storage/trackBlobs.php
@@ -12,6 +12,7 @@ if ( count( $args ) < 1 ) {
}
$tracker = new TrackBlobs( $args );
$tracker->run();
+echo "All done.\n";
class TrackBlobs {
var $clusters, $textClause;
@@ -59,7 +60,7 @@ class TrackBlobs {
if ( $this->textClause != '' ) {
$this->textClause .= ' OR ';
}
- $this->textClause .= 'old_text LIKE ' . $dbr->addQuotes( $dbr->escapeLike( "DB://$cluster/" ) . '%' );
+ $this->textClause .= 'old_text' . $dbr->buildLike( "DB://$cluster/", $dbr->anyString() );
}
}
return $this->textClause;
@@ -72,7 +73,7 @@ class TrackBlobs {
return array(
'cluster' => $m[1],
'id' => intval( $m[2] ),
- 'hash' => isset( $m[3] ) ? $m[2] : null
+ 'hash' => isset( $m[3] ) ? $m[3] : null
);
}
@@ -98,7 +99,7 @@ class TrackBlobs {
'rev_id > ' . $dbr->addQuotes( $startId ),
'rev_text_id=old_id',
$textClause,
- "old_flags LIKE '%external%'",
+ 'old_flags ' . $dbr->buildLike( $dbr->anyString(), 'external', $dbr->anyString() ),
),
__METHOD__,
array(
@@ -174,7 +175,7 @@ class TrackBlobs {
array(
'old_id>' . $dbr->addQuotes( $startId ),
$textClause,
- "old_flags LIKE '%external%'",
+ 'old_flags ' . $dbr->buildLike( $dbr->anyString(), 'external', $dbr->anyString() ),
'bt_text_id IS NULL'
),
__METHOD__,
@@ -263,6 +264,10 @@ class TrackBlobs {
if ( is_null( $table ) ) {
$table = 'blobs';
}
+ if ( !$extDB->tableExists( $table ) ) {
+ echo "No blobs table on cluster $cluster\n";
+ continue;
+ }
$startId = 0;
$batchesDone = 0;
$actualBlobs = gmp_init( 0 );
@@ -300,6 +305,7 @@ class TrackBlobs {
// Traverse the orphan list
$insertBatch = array();
$id = 0;
+ $numOrphans = 0;
while ( true ) {
$id = gmp_scan1( $orphans, $id );
if ( $id == -1 ) {
@@ -309,12 +315,18 @@ class TrackBlobs {
'bo_cluster' => $cluster,
'bo_blob_id' => $id
);
+ if ( count( $insertBatch ) > $this->batchSize ) {
+ $dbw->insert( 'blob_orphans', $insertBatch, __METHOD__ );
+ $insertBatch = array();
+ }
+
++$id;
+ ++$numOrphans;
}
-
- // Insert the batch
- echo "Found " . count( $insertBatch ) . " orphan(s) in $cluster\n";
- $dbw->insert( 'blob_orphans', $insertBatch, __METHOD__ );
+ if ( $insertBatch ) {
+ $dbw->insert( 'blob_orphans', $insertBatch, __METHOD__ );
+ }
+ echo "Found $numOrphans orphan(s) in $cluster\n";
}
}
}