r83707 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83706‎ | r83707 | r83708 >
Date:18:39, 11 March 2011
Author:yaron
Status:ok
Tags:
Comment:
Made some improvements to SQL, including use of addQuotes() - follow-up to r82212
Modified paths:
  • /trunk/extensions/ReplaceText/SpecialReplaceText.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ReplaceText/SpecialReplaceText.php
@@ -508,19 +508,17 @@
509509 function getMatchingTitles( $str, $namespaces, $category, $prefix, $use_regex = false ) {
510510 $dbr = wfGetDB( DB_SLAVE );
511511
512 - $str = Title::newFromText( $str )->getDbKey();
513 -
514512 $tables = array( 'page' );
515513 $vars = array( 'page_title', 'page_namespace' );
516514 if ( $use_regex ) {
517 - $comparisonCond = "page_title REGEXP '$str'";
 515+ $comparisonCond = 'page_title REGEXP ' . $dbr->addQuotes( $str );
518516 } else {
519517 // anyString() method was added in MW 1.16
520518 if ( method_exists( $dbr, 'anyString' ) ) {
521519 $any = $dbr->anyString();
522520 $comparisonCond = 'page_title ' . $dbr->buildLike( $any, $str, $any );
523521 } else {
524 - $comparisonCond = "page_title LIKE '%$str%'";
 522+ $comparisonCond = 'page_title LIKE ' . $dbr->addQuotes( "%$str%" );
525523 }
526524 }
527525 $conds = array(
@@ -540,14 +538,14 @@
541539 $tables = array( 'page', 'revision', 'text' );
542540 $vars = array( 'page_id', 'page_namespace', 'page_title', 'old_text' );
543541 if ( $use_regex ) {
544 - $comparisonCond = "old_text REGEXP '$search'";
 542+ $comparisonCond = 'old_text REGEXP ' . $dbr->addQuotes( $search );
545543 } else {
546544 // anyString() method was added in MW 1.16
547545 if ( method_exists( $dbr, 'anyString' ) ) {
548546 $any = $dbr->anyString();
549547 $comparisonCond = 'old_text ' . $dbr->buildLike( $any, $search, $any );
550548 } else {
551 - $comparisonCond = "old_text LIKE '%$search%'";
 549+ $comparisonCond = 'old_text LIKE ' . $dbr->addQuotes( "%$search%" );
552550 }
553551 }
554552 $conds = array(

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r82212Added handling for regular expressionsyaron03:11, 16 February 2011

Status & tagging log