Index: trunk/phase3/maintenance/fuzz-tester.php |
— | — | @@ -816,21 +816,22 @@ |
817 | 817 | } |
818 | 818 | } |
819 | 819 | |
820 | | - |
821 | 820 | /** |
| 821 | + * Returns the matched character slash-escaped as in a C string |
| 822 | + * Helper for makeTitleSafe callback |
| 823 | + */ |
| 824 | + static private function stringEscape($matches) { |
| 825 | + return sprintf( "\\x%02x", ord( $matches[1] ) ); |
| 826 | + } |
| 827 | + |
| 828 | + /** |
822 | 829 | ** Strips out the stuff that Mediawiki balks at in a page's title. |
823 | 830 | ** Implementation copied/pasted from cleanupTable.inc & cleanupImages.php |
824 | 831 | */ |
825 | 832 | static public function makeTitleSafe( $str ) { |
826 | 833 | $legalTitleChars = " %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF"; |
827 | 834 | return preg_replace_callback( |
828 | | - "/([^$legalTitleChars])/", |
829 | | - create_function( |
830 | | - // single quotes are essential here, |
831 | | - // or alternative escape all $ as \$ |
832 | | - '$matches', |
833 | | - 'return sprintf( "\\x%02x", ord( $matches[1] ) );' |
834 | | - ), |
| 835 | + "/([^$legalTitleChars])/", 'wikiFuzz::stringEscape', |
835 | 836 | $str ); |
836 | 837 | } |
837 | 838 | |
Index: trunk/phase3/maintenance/upgrade1_5.php |
— | — | @@ -320,6 +320,12 @@ |
321 | 321 | $this->dbw->insert( $this->chunkTable, $chunk, $this->chunkFunction, $this->chunkOptions ); |
322 | 322 | } |
323 | 323 | |
| 324 | + /** |
| 325 | + * Helper function for copyTable array_filter |
| 326 | + */ |
| 327 | + static private function notUpgradeNull($x) { |
| 328 | + return $x !== MW_UPGRADE_NULL; |
| 329 | + } |
324 | 330 | |
325 | 331 | /** |
326 | 332 | * Copy and transcode a table to table_temp. |
— | — | @@ -349,8 +355,7 @@ |
350 | 356 | $this->setChunkScale( 100, $numRecords, $name_temp, __METHOD__ ); |
351 | 357 | |
352 | 358 | // Pull all records from the second, streaming database connection. |
353 | | - $sourceFields = array_keys( array_filter( $fields, |
354 | | - create_function( '$x', 'return $x !== MW_UPGRADE_NULL;' ) ) ); |
| 359 | + $sourceFields = array_keys( array_filter( $fields, 'FiveUpgrade::notUpgradeNull' ) ); |
355 | 360 | $result = $this->dbr->select( $name, |
356 | 361 | $sourceFields, |
357 | 362 | '', |