diff --git a/SpecialReplaceText.php b/SpecialReplaceText.php index e9d0557d..01264d29 100644 --- a/SpecialReplaceText.php +++ b/SpecialReplaceText.php @@ -125,7 +125,9 @@ function doSpecialReplaceText() { $talk_ns = NS_TALK; $usertalk_ns = NS_USER_TALK; $mediawiki_ns = NS_MEDIAWIKI; - $sql_target_str = str_replace("'", "\'", $target_str); + // escape single quote and backslash for SQL - for some reason, the + // backslash needs to be escaped twice (plus once for PHP) + $sql_target_str = str_replace(array("'", "\\"), array("\'", "\\\\\\\\"), $target_str); $sql = "SELECT p.page_title AS title, p.page_namespace AS namespace, t.old_text AS text FROM $page_table p JOIN $revision_table r ON p.page_latest = r.rev_id @@ -187,13 +189,19 @@ END; list($title, $context_str) = $value_pair; $text .= "getArticleID()}\" checked /> {$skin->makeLinkObj( $title, $title->prefix($title->getText()) )} - $context_str
\n"; } - $invert_selections_label = wfMsg('replacetext_invertselections'); $text .=<<

-

$invert_selections_label

- END; + // only show "invert selections" link if there are more than five pages + if (count($found_titles) > 5) { + $invert_selections_label = wfMsg('replacetext_invertselections'); + $text .=<<$invert_selections_label

+ +END; + } + $text .= " \n"; $wgOut->addHTML($text); } } else {