aboutsummaryrefslogtreecommitdiffstats
path: root/maintenance/storage/trackBlobs.php
diff options
context:
space:
mode:
Diffstat (limited to 'maintenance/storage/trackBlobs.php')
-rw-r--r--maintenance/storage/trackBlobs.php45
1 files changed, 34 insertions, 11 deletions
diff --git a/maintenance/storage/trackBlobs.php b/maintenance/storage/trackBlobs.php
index 2dd48caf98df..385ae6a5a00e 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';
@@ -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;