51 $fname =
'moveToExternal';
55 $count = $maxID - $minID + 1;
57 $numBlocks = ceil( $count / $blockSize );
58 print "Moving text rows from $minID to $maxID to external storage\n";
60 $esFactory = MediaWikiServices::getInstance()->getExternalStoreFactory();
61 $extStore = $esFactory->getStore(
$type );
64 for ( $block = 0; $block < $numBlocks; $block++ ) {
65 $blockStart = $block * $blockSize + $minID;
66 $blockEnd = $blockStart + $blockSize - 1;
69 print "oldid=$blockStart, moved=$numMoved\n";
73 $res =
$dbr->select(
'text', [
'old_id',
'old_flags',
'old_text' ],
75 "old_id BETWEEN $blockStart AND $blockEnd",
76 'old_flags NOT ' .
$dbr->buildLike(
$dbr->anyString(),
'external',
$dbr->anyString() ),
78 foreach (
$res as $row ) {
80 $text = $row->old_text;
82 if ( $row->old_flags ===
'' ) {
85 $flags =
"{$row->old_flags},external";
88 if ( strpos( $flags,
'object' ) !==
false ) {
90 $className = strtolower( get_class( $obj ) );
91 if ( $className ==
'historyblobstub' ) {
92 # resolveStub( $id, $row->old_text, $row->old_flags );
95 } elseif ( $className ==
'historyblobcurstub' ) {
96 $text = gzdeflate( $obj->getText() );
97 $flags =
'utf-8,gzip,external';
98 } elseif ( $className ==
'concatenatedgziphistoryblob' ) {
101 print "Warning: unrecognised object class \"$className\"\n";
108 if ( strlen( $text ) < 100 && $className ===
false ) {
113 # print "Storing " . strlen( $text ) . " bytes to $url\n";
114 # print "old_id=$id\n";
116 $url = $extStore->store( $location, $text );
118 print "Error writing to external storage\n";
121 $dbw->update(
'text',
122 [
'old_flags' => $flags,
'old_text' => $url ],
123 [
'old_id' => $id ], $fname );
wfWaitForSlaves( $ifWritesSince=null, $wiki=false, $cluster=false, $timeout=null)
Waits for the replica DBs to catch up to the master position.