of using showFatalError directly: OutputPage::showFileDeleteError()
OutputPage::showFileNotFoundError(), OutputPage::showFileRenameError()
OutputPage::showFileCopyError() and OutputPage::showUnexpectedValueError().
-
+* The Replacer, DoubleReplacer, HashtableReplacer, and RegexlikeReplacer
+ classes are now deprecated. Use a Closure instead.
=== Other changes in 1.32 ===
* (T198811) The following tables have had their UNIQUE indexes turned into proper
* @return string The string with the matches replaced
*/
static function delimiterReplace( $startDelim, $endDelim, $replace, $subject, $flags = '' ) {
- $replacer = new RegexlikeReplacer( $replace );
-
- return self::delimiterReplaceCallback( $startDelim, $endDelim,
- $replacer->cb(), $subject, $flags );
+ return self::delimiterReplaceCallback(
+ $startDelim, $endDelim,
+ function ( array $matches ) use ( $replace ) {
+ return strtr( $replace, [ '$0' => $matches[0], '$1' => $matches[1] ] );
+ },
+ $subject, $flags
+ );
}
/**
$text = str_replace( $placeholder, '', $text );
// Replace instances of the separator inside HTML-like tags with the placeholder
- $replacer = new DoubleReplacer( $separator, $placeholder );
- $cleaned = self::delimiterReplaceCallback( '<', '>', $replacer->cb(), $text );
+ $cleaned = self::delimiterReplaceCallback(
+ '<', '>',
+ function ( array $matches ) use ( $separator, $placeholder ) {
+ return str_replace( $separator, $placeholder, $matches[0] );
+ },
+ $text
+ );
// Explode, then put the replaced separators back in
$items = explode( $separator, $cleaned );
$text = str_replace( $placeholder, '', $text );
// Replace instances of the separator inside HTML-like tags with the placeholder
- $replacer = new DoubleReplacer( $search, $placeholder );
- $cleaned = self::delimiterReplaceCallback( '<', '>', $replacer->cb(), $text );
+ $cleaned = self::delimiterReplaceCallback(
+ '<', '>',
+ function ( array $matches ) use ( $search, $placeholder ) {
+ return str_replace( $search, $placeholder, $matches[0] );
+ },
+ $text
+ );
// Explode, then put the replaced separators back in
$cleaned = str_replace( $search, $replace, $cleaned );
$replacePairs[$searchkey] = $link;
}
}
- $replacer = new HashtableReplacer( $replacePairs, 1 );
# Do the thing
$text = preg_replace_callback(
'/(<!--LINK\'" .*?-->)/',
- $replacer->cb(),
+ function ( array $matches ) use ( $replacePairs ) {
+ return $replacePairs[$matches[1]];
+ },
$text
);
}
);
$output->addInterwikiLink( $link['title'] );
}
- $replacer = new HashtableReplacer( $replacePairs, 1 );
$text = preg_replace_callback(
'/<!--IWLINK\'" (.*?)-->/',
- $replacer->cb(),
- $text );
+ function ( array $matches ) use ( $replacePairs ) {
+ return $replacePairs[$matches[1]];
+ },
+ $text
+ );
}
/**