27 if ( !defined(
'MEDIAWIKI' ) ) {
30 require_once __DIR__ .
'/../CommandLineInc.php';
40 $fname =
'resolveStubs';
43 $maxID =
$dbr->selectField(
'text',
'MAX(old_id)',
'', $fname );
45 $numBlocks = intval( $maxID / $blockSize ) + 1;
46 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
48 for ( $b = 0; $b < $numBlocks; $b++ ) {
49 $lbFactory->waitForReplication();
51 printf(
"%5.2f%%\n", $b / $numBlocks * 100 );
52 $start = intval( $maxID / $numBlocks ) * $b + 1;
53 $end = intval( $maxID / $numBlocks ) * ( $b + 1 );
55 $res =
$dbr->select(
'text', [
'old_id',
'old_text',
'old_flags' ],
56 "old_id>=$start AND old_id<=$end " .
57 "AND old_flags LIKE '%object%' AND old_flags NOT LIKE '%external%' " .
58 'AND LOWER(CONVERT(LEFT(old_text,22) USING latin1)) = \'o:15:"historyblobstub"\'',
60 foreach (
$res as $row ) {
61 resolveStub( $row->old_id, $row->old_text, $row->old_flags );
74 $fname =
'resolveStub';
77 $flags = explode(
',', $flags );
82 if ( strtolower( get_class( $stub ) ) !==
'historyblobstub' ) {
83 print
"Error found object of class " . get_class( $stub ) .
", expecting historyblobstub\n";
88 # Get the (maybe) external row
89 $externalRow =
$dbr->selectRow(
93 'old_id' => $stub->getLocation(),
94 'old_flags' .
$dbr->buildLike(
$dbr->anyString(),
'external',
$dbr->anyString() )
99 if ( !$externalRow ) {
100 # Object wasn't external
104 # Preserve the legacy encoding flag, but switch from object to external
105 if ( in_array(
'utf-8', $flags ) ) {
106 $newFlags =
'external,utf-8';
108 $newFlags =
'external';
112 # print "oldid=$id\n";
113 $dbw->update(
'text',
115 'old_flags' => $newFlags,
116 'old_text' => $externalRow->old_text .
'/' . $stub->getHash()
unserialize( $serialized)
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
if(!defined( 'MEDIAWIKI')) resolveStubs()
Convert history stubs that point to an external row to direct external pointers.
resolveStub( $id, $stubText, $flags)
Resolve a history stub.