Index: trunk/phase3/maintenance/storage/fixBug20757.php |
— | — | @@ -39,7 +39,8 @@ |
40 | 40 | array( 'old_id', 'old_flags', 'old_text' ), |
41 | 41 | array( |
42 | 42 | 'old_id > ' . intval( $startId ), |
43 | | - 'old_flags ' . $dbr->buildLike( $dbr->anyString(), 'object', $dbr->anyString ) |
| 43 | + 'old_flags LIKE \'%object%\' AND old_flags NOT LIKE \'%external%\'', |
| 44 | + 'LOWER(CONVERT(LEFT(old_text,22) USING latin1)) = \'o:15:"historyblobstub"\'', |
44 | 45 | ), |
45 | 46 | __METHOD__, |
46 | 47 | array( |
— | — | @@ -80,10 +81,19 @@ |
81 | 82 | continue; |
82 | 83 | } |
83 | 84 | |
| 85 | + // Process flags |
| 86 | + $flags = explode( ',', $row->old_flags ); |
| 87 | + if ( in_array( 'utf-8', $flags ) || in_array( 'utf8', $flags ) ) { |
| 88 | + $legacyEncoding = false; |
| 89 | + } else { |
| 90 | + $legacyEncoding = true; |
| 91 | + } |
| 92 | + |
84 | 93 | // Queue the stub for future batch processing |
85 | 94 | $id = intval( $obj->mOldId ); |
86 | 95 | $secondaryIds[] = $id; |
87 | 96 | $stubs[$row->old_id] = array( |
| 97 | + 'legacyEncoding' => $legacyEncoding, |
88 | 98 | 'secondaryId' => $id, |
89 | 99 | 'hash' => $obj->mHash, |
90 | 100 | ); |
— | — | @@ -101,7 +111,6 @@ |
102 | 112 | '*', |
103 | 113 | array( |
104 | 114 | 'bt_text_id' => $secondaryIds, |
105 | | - 'bt_moved' => 1, |
106 | 115 | ), |
107 | 116 | __METHOD__ |
108 | 117 | ); |
— | — | @@ -170,6 +179,8 @@ |
171 | 180 | } |
172 | 181 | } |
173 | 182 | |
| 183 | + $newFlags = $stub['legacyEncoding'] ? 'external' : 'external,utf-8'; |
| 184 | + |
174 | 185 | if ( !$dryRun ) { |
175 | 186 | // Reset the text row to point to the original copy |
176 | 187 | $dbw->begin(); |
— | — | @@ -177,7 +188,7 @@ |
178 | 189 | 'text', |
179 | 190 | // SET |
180 | 191 | array( |
181 | | - 'old_flags' => 'external', // use legacy encoding |
| 192 | + 'old_flags' => $newFlags, |
182 | 193 | 'old_text' => $url |
183 | 194 | ), |
184 | 195 | // WHERE |
— | — | @@ -264,22 +275,23 @@ |
265 | 276 | */ |
266 | 277 | function isUnbrokenStub( $stub, $secondaryRow ) { |
267 | 278 | $flags = explode( ',', $secondaryRow->old_flags ); |
| 279 | + $text = $secondaryRow->old_text; |
268 | 280 | if( in_array( 'external', $flags ) ) { |
269 | | - $url = $secondaryRow->old_text; |
| 281 | + $url = $text; |
270 | 282 | @list( /* $proto */ , $path ) = explode( '://', $url, 2 ); |
271 | 283 | if ( $path == "" ) { |
272 | 284 | return false; |
273 | 285 | } |
274 | | - $secondaryRow->old_text = ExternalStore::fetchFromUrl( $url ); |
| 286 | + $text = ExternalStore::fetchFromUrl( $url ); |
275 | 287 | } |
276 | 288 | if( !in_array( 'object', $flags ) ) { |
277 | 289 | return false; |
278 | 290 | } |
279 | 291 | |
280 | 292 | if( in_array( 'gzip', $flags ) ) { |
281 | | - $obj = unserialize( gzinflate( $secondaryRow->old_text ) ); |
| 293 | + $obj = unserialize( gzinflate( $text ) ); |
282 | 294 | } else { |
283 | | - $obj = unserialize( $secondaryRow->old_text ); |
| 295 | + $obj = unserialize( $text ); |
284 | 296 | } |
285 | 297 | |
286 | 298 | if( !is_object( $obj ) ) { |
Index: trunk/phase3/maintenance/storage/resolveStubs.php |
— | — | @@ -35,11 +35,9 @@ |
36 | 36 | |
37 | 37 | $res = $dbr->select( 'text', array( 'old_id', 'old_text', 'old_flags' ), |
38 | 38 | "old_id>=$start AND old_id<=$end " . |
39 | | - # Using a more restrictive flag set for now, until I do some more analysis -- TS |
40 | | - #"AND old_flags LIKE '%object%' AND old_flags NOT LIKE '%external%' ". |
41 | | - |
42 | | - "AND old_flags='object' " . |
43 | | - "AND LOWER(LEFT(old_text,22)) = 'O:15:\"historyblobstub\"'", $fname ); |
| 39 | + "AND old_flags LIKE '%object%' AND old_flags NOT LIKE '%external%' ". |
| 40 | + 'AND LOWER(CONVERT(LEFT(old_text,22) USING latin1)) = \'o:15:"historyblobstub"\'', |
| 41 | + $fname ); |
44 | 42 | while ( $row = $dbr->fetchObject( $res ) ) { |
45 | 43 | resolveStub( $row->old_id, $row->old_text, $row->old_flags ); |
46 | 44 | } |
Index: trunk/phase3/maintenance/storage/trackBlobs.php |
— | — | @@ -73,7 +73,7 @@ |
74 | 74 | return array( |
75 | 75 | 'cluster' => $m[1], |
76 | 76 | 'id' => intval( $m[2] ), |
77 | | - 'hash' => isset( $m[3] ) ? $m[2] : null |
| 77 | + 'hash' => isset( $m[3] ) ? $m[3] : null |
78 | 78 | ); |
79 | 79 | } |
80 | 80 | |