Index: trunk/extensions/ReplaceText/SpecialReplaceText.php |
— | — | @@ -16,7 +16,7 @@ |
17 | 17 | |
18 | 18 | $this->user = $wgUser; |
19 | 19 | $this->setHeaders(); |
20 | | - if ( method_exists( $wgOut, 'addModuleStyles' ) && |
| 20 | + if ( method_exists( $wgOut, 'addModuleStyles' ) && |
21 | 21 | !is_null( $wgOut->getResourceLoader()->getModule( 'mediawiki.special' ) ) ) { |
22 | 22 | $wgOut->addModuleStyles( 'mediawiki.special' ); |
23 | 23 | } |
— | — | @@ -85,7 +85,7 @@ |
86 | 86 | } |
87 | 87 | $jobs = array(); |
88 | 88 | foreach ( $wgRequest->getValues() as $key => $value ) { |
89 | | - if ( $value == '1' && $key !== 'replace' ) { |
| 89 | + if ( $value == '1' && $key !== 'replace' && $key !== 'use_regex' ) { |
90 | 90 | if ( strpos( $key, 'move-' ) !== false ) { |
91 | 91 | $title = Title::newFromID( substr( $key, 5 ) ); |
92 | 92 | $replacement_params['move_page'] = true; |
— | — | @@ -516,7 +516,7 @@ |
517 | 517 | |
518 | 518 | $str = str_replace( ' ', '_', $str ); |
519 | 519 | if ( $use_regex ) { |
520 | | - $comparisonCond = 'page_title REGEXP ' . $dbr->addQuotes( $str ); |
| 520 | + $comparisonCond = $this->regexCond( $dbr, 'page_title', $str ); |
521 | 521 | } else { |
522 | 522 | $any = $dbr->anyString(); |
523 | 523 | $comparisonCond = 'page_title ' . $dbr->buildLike( $any, $str, $any ); |
— | — | @@ -538,7 +538,7 @@ |
539 | 539 | $tables = array( 'page', 'revision', 'text' ); |
540 | 540 | $vars = array( 'page_id', 'page_namespace', 'page_title', 'old_text' ); |
541 | 541 | if ( $use_regex ) { |
542 | | - $comparisonCond = 'old_text REGEXP ' . $dbr->addQuotes( $search ); |
| 542 | + $comparisonCond = $this->regexCond( $dbr, 'old_text', $search ); |
543 | 543 | } else { |
544 | 544 | $any = $dbr->anyString(); |
545 | 545 | $comparisonCond = 'old_text ' . $dbr->buildLike( $any, $search, $any ); |
— | — | @@ -580,4 +580,12 @@ |
581 | 581 | $conds[] = 'page_title ' . $dbr->buildLike( $prefix, $any ); |
582 | 582 | } |
583 | 583 | |
| 584 | + private function regexCond( $dbr, $column, $regex ) { |
| 585 | + if ( $dbr instanceof DatabasePostgres ) { |
| 586 | + $op = '~'; |
| 587 | + } else { |
| 588 | + $op = 'REGEXP'; |
| 589 | + } |
| 590 | + return "$column $op " . $dbr->addQuotes( $regex ); |
| 591 | + } |
584 | 592 | } |