X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=maintenance%2Fstorage%2FtrackBlobs.php;h=385ae6a5a00eb960fccca7cdb3cb887e27758eae;hb=c3e549a732b8ed47973a28aa350d3c5b6b96928c;hp=36b6f5b459af64fdb8a13765a8a401fe38a65455;hpb=7583ead42626fba866096f6ffef6594df0321065;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/storage/trackBlobs.php b/maintenance/storage/trackBlobs.php index 36b6f5b459..385ae6a5a0 100644 --- a/maintenance/storage/trackBlobs.php +++ b/maintenance/storage/trackBlobs.php @@ -23,6 +23,7 @@ */ use MediaWiki\MediaWikiServices; +use MediaWiki\Revision\SlotRecord; use Wikimedia\Rdbms\DBConnectionError; require __DIR__ . '/../commandLine.inc'; @@ -122,7 +123,7 @@ class TrackBlobs { return [ 'cluster' => $m[1], 'id' => intval( $m[2] ), - 'hash' => isset( $m[3] ) ? $m[3] : null + 'hash' => $m[3] ?? null ]; } @@ -130,6 +131,8 @@ class TrackBlobs { * Scan the revision table for rows stored in the specified clusters */ function trackRevisions() { + global $wgMultiContentRevisionSchemaMigrationStage; + $dbw = wfGetDB( DB_MASTER ); $dbr = wfGetDB( DB_REPLICA ); @@ -141,20 +144,40 @@ class TrackBlobs { echo "Finding revisions...\n"; + $fields = [ 'rev_id', 'rev_page', 'old_id', 'old_flags', 'old_text' ]; + $options = [ + 'ORDER BY' => 'rev_id', + 'LIMIT' => $this->batchSize + ]; + $conds = [ + $textClause, + 'old_flags ' . $dbr->buildLike( $dbr->anyString(), 'external', $dbr->anyString() ), + ]; + if ( $wgMultiContentRevisionSchemaMigrationStage & SCHEMA_COMPAT_READ_OLD ) { + $tables = [ 'revision', 'text' ]; + $conds = array_merge( [ + 'rev_text_id=old_id', + ], $conds ); + } else { + $slotRoleStore = MediaWikiServices::getInstance()->getSlotRoleStore(); + $tables = [ 'revision', 'slots', 'content', 'text' ]; + $conds = array_merge( [ + 'rev_id=slot_revision_id', + 'slot_role_id=' . $slotRoleStore->getId( SlotRecord::MAIN ), + 'content_id=slot_content_id', + 'SUBSTRING(content_address, 1, 3)=' . $dbr->addQuotes( 'tt:' ), + 'SUBSTRING(content_address, 4)=old_id', + ], $conds ); + } + while ( true ) { - $res = $dbr->select( [ 'revision', 'text' ], - [ 'rev_id', 'rev_page', 'old_id', 'old_flags', 'old_text' ], - [ + $res = $dbr->select( $tables, + $fields, + array_merge( [ 'rev_id > ' . $dbr->addQuotes( $startId ), - 'rev_text_id=old_id', - $textClause, - 'old_flags ' . $dbr->buildLike( $dbr->anyString(), 'external', $dbr->anyString() ), - ], + ], $conds ), __METHOD__, - [ - 'ORDER BY' => 'rev_id', - 'LIMIT' => $this->batchSize - ] + $options ); if ( !$res->numRows() ) { break;