array( 'old_id', 'old_flags', 'old_text' ),
array(
'old_id > ' . intval( $startId ),
- 'old_flags ' . $dbr->buildLike( $dbr->anyString(), 'object', $dbr->anyString )
+ 'old_flags LIKE \'%object%\' AND old_flags NOT LIKE \'%external%\'',
+ 'LOWER(CONVERT(LEFT(old_text,22) USING latin1)) = \'o:15:"historyblobstub"\'',
),
__METHOD__,
array(
continue;
}
+ // Process flags
+ $flags = explode( ',', $row->old_flags );
+ if ( in_array( 'utf-8', $flags ) || in_array( 'utf8', $flags ) ) {
+ $legacyEncoding = false;
+ } else {
+ $legacyEncoding = true;
+ }
+
// Queue the stub for future batch processing
$id = intval( $obj->mOldId );
$secondaryIds[] = $id;
$stubs[$row->old_id] = array(
+ 'legacyEncoding' => $legacyEncoding,
'secondaryId' => $id,
'hash' => $obj->mHash,
);
'*',
array(
'bt_text_id' => $secondaryIds,
- 'bt_moved' => 1,
),
__METHOD__
);
}
}
+ $newFlags = $stub['legacyEncoding'] ? 'external' : 'external,utf-8';
+
if ( !$dryRun ) {
// Reset the text row to point to the original copy
$dbw->begin();
'text',
// SET
array(
- 'old_flags' => 'external', // use legacy encoding
+ 'old_flags' => $newFlags,
'old_text' => $url
),
// WHERE
*/
function isUnbrokenStub( $stub, $secondaryRow ) {
$flags = explode( ',', $secondaryRow->old_flags );
+ $text = $secondaryRow->old_text;
if( in_array( 'external', $flags ) ) {
- $url = $secondaryRow->old_text;
+ $url = $text;
@list( /* $proto */ , $path ) = explode( '://', $url, 2 );
if ( $path == "" ) {
return false;
}
- $secondaryRow->old_text = ExternalStore::fetchFromUrl( $url );
+ $text = ExternalStore::fetchFromUrl( $url );
}
if( !in_array( 'object', $flags ) ) {
return false;
}
if( in_array( 'gzip', $flags ) ) {
- $obj = unserialize( gzinflate( $secondaryRow->old_text ) );
+ $obj = unserialize( gzinflate( $text ) );
} else {
- $obj = unserialize( $secondaryRow->old_text );
+ $obj = unserialize( $text );
}
if( !is_object( $obj ) ) {
$res = $dbr->select( 'text', array( 'old_id', 'old_text', 'old_flags' ),
"old_id>=$start AND old_id<=$end " .
- # Using a more restrictive flag set for now, until I do some more analysis -- TS
- #"AND old_flags LIKE '%object%' AND old_flags NOT LIKE '%external%' ".
-
- "AND old_flags='object' " .
- "AND LOWER(LEFT(old_text,22)) = 'O:15:\"historyblobstub\"'", $fname );
+ "AND old_flags LIKE '%object%' AND old_flags NOT LIKE '%external%' ".
+ 'AND LOWER(CONVERT(LEFT(old_text,22) USING latin1)) = \'o:15:"historyblobstub"\'',
+ $fname );
while ( $row = $dbr->fetchObject( $res ) ) {
resolveStub( $row->old_id, $row->old_text, $row->old_flags );
}