}
}
-
+ /**
+ * Returns the matched character slash-escaped as in a C string
+ * Helper for makeTitleSafe callback
+ */
+ static private function stringEscape($matches) {
+ return sprintf( "\\x%02x", ord( $matches[1] ) );
+ }
+
/**
** Strips out the stuff that Mediawiki balks at in a page's title.
** Implementation copied/pasted from cleanupTable.inc & cleanupImages.php
static public function makeTitleSafe( $str ) {
$legalTitleChars = " %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF";
return preg_replace_callback(
- "/([^$legalTitleChars])/",
- create_function(
- // single quotes are essential here,
- // or alternative escape all $ as \$
- '$matches',
- 'return sprintf( "\\x%02x", ord( $matches[1] ) );'
- ),
+ "/([^$legalTitleChars])/", 'wikiFuzz::stringEscape',
$str );
}
$this->dbw->insert( $this->chunkTable, $chunk, $this->chunkFunction, $this->chunkOptions );
}
+ /**
+ * Helper function for copyTable array_filter
+ */
+ static private function notUpgradeNull($x) {
+ return $x !== MW_UPGRADE_NULL;
+ }
/**
* Copy and transcode a table to table_temp.
$this->setChunkScale( 100, $numRecords, $name_temp, __METHOD__ );
// Pull all records from the second, streaming database connection.
- $sourceFields = array_keys( array_filter( $fields,
- create_function( '$x', 'return $x !== MW_UPGRADE_NULL;' ) ) );
+ $sourceFields = array_keys( array_filter( $fields, 'FiveUpgrade::notUpgradeNull' ) );
$result = $this->dbr->select( $name,
$sourceFields,
'',