"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "extensions/ReplaceText/src/ReplaceTextSearch.php" between
mediawiki-1.31.1.tar.gz and mediawiki-1.32.0.tar.gz

About: MediaWiki is a wiki engine (the collaborative editing software that runs for e.g. Wikipedia, the free encyclopedia).

ReplaceTextSearch.php  (mediawiki-1.31.1):ReplaceTextSearch.php  (mediawiki-1.32.0)
skipping to change at line 111 skipping to change at line 111
* @return string query condition for regex * @return string query condition for regex
*/ */
public static function regexCond( $dbr, $column, $regex ) { public static function regexCond( $dbr, $column, $regex ) {
if ( $dbr->getType() == 'postgres' ) { if ( $dbr->getType() == 'postgres' ) {
$op = '~'; $op = '~';
} else { } else {
$op = 'REGEXP'; $op = 'REGEXP';
} }
return "$column $op " . $dbr->addQuotes( $regex ); return "$column $op " . $dbr->addQuotes( $regex );
} }
/**
* @param string $str
* @param array $namespaces
* @param string $category
* @param string $prefix
* @param bool $use_regex
* @return IResultWrapper Resulting rows
*/
public static function getMatchingTitles(
$str,
$namespaces,
$category,
$prefix,
$use_regex = false
) {
$dbr = wfGetDB( DB_REPLICA );
$tables = [ 'page' ];
$vars = [ 'page_title', 'page_namespace' ];
$str = str_replace( ' ', '_', $str );
if ( $use_regex ) {
$comparisonCond = self::regexCond( $dbr, 'page_title', $s
tr );
} else {
$any = $dbr->anyString();
$comparisonCond = 'page_title ' . $dbr->buildLike( $any,
$str, $any );
}
$conds = [
$comparisonCond,
'page_namespace' => $namespaces,
];
self::categoryCondition( $category, $tables, $conds );
self::prefixCondition( $prefix, $conds );
$sort = [ 'ORDER BY' => 'page_namespace, page_title' ];
return $dbr->select( $tables, $vars, $conds, __METHOD__, $sort );
}
/**
* Do a replacement on a string.
* @param string $text
* @param string $search
* @param string $replacement
* @param bool $regex
* @return string
*/
public static function getReplacedText( $text, $search, $replacement, $re
gex ) {
if ( $regex ) {
$escapedSearch = addcslashes( $search, '/' );
return preg_replace( "/$escapedSearch/Uu", $replacement,
$text );
} else {
return str_replace( $search, $replacement, $text );
}
}
/**
* Do a replacement on a title.
* @param Title $title
* @param string $search
* @param string $replacement
* @param bool $regex
* @return Title|null
*/
public static function getReplacedTitle( Title $title, $search, $replacem
ent, $regex ) {
$oldTitleText = $title->getText();
$newTitleText = self::getReplacedText( $oldTitleText, $search, $r
eplacement, $regex );
return Title::makeTitleSafe( $title->getNamespace(), $newTitleTex
t );
}
} }
 End of changes. 1 change blocks. 
0 lines changed or deleted 77 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)