r70154 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70153‎ | r70154 | r70155 >
Date:18:25, 29 July 2010
Author:nikerabbit
Status:ok
Tags:
Comment:
Use buildLike instead of escapeLike. Latter fails on sqlite.
Modified paths:
  • /trunk/extensions/Translate/tag/SpecialPageTranslation.php (modified) (history)
  • /trunk/extensions/Translate/tag/SpecialPageTranslationMovePage.php (modified) (history)
  • /trunk/extensions/Translate/tag/TranslatablePage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/tag/TranslatablePage.php
@@ -448,13 +448,14 @@
449449 public function getTranslationPages() {
450450 // Fetch the available translation pages from database
451451 $dbr = wfGetDB( DB_SLAVE );
452 - $likePattern = $dbr->escapeLike( $this->getTitle()->getDBkey() ) . '/%%';
 452+ $prefix = $this->getTitle()->getDBkey() . '/';
 453+ $likePattern = $dbr->buildLike( $prefix, $dbr->anyString() );
453454 $res = $dbr->select(
454455 'page',
455456 array( 'page_namespace', 'page_title' ),
456457 array(
457458 'page_namespace' => $this->getTitle()->getNamespace(),
458 - "page_title LIKE '$likePattern'"
 459+ "page_title $likePattern"
459460 ),
460461 __METHOD__
461462 );
Index: trunk/extensions/Translate/tag/SpecialPageTranslation.php
@@ -524,7 +524,7 @@
525525 foreach ( $changed as $c ) {
526526 $title = Title::makeTitleSafe( NS_TRANSLATIONS, "$prefix/$c" );
527527 if ( $title ) {
528 - $titles[] = 'page_title like \'' . $db->escapeLike( $title->getDBkey() ) . '/%\'';
 528+ $titles[] = 'page_title ' . $db->buildLike( $title->getDBkey() . '/', $db->anyString() );
529529 }
530530 }
531531
Index: trunk/extensions/Translate/tag/SpecialPageTranslationMovePage.php
@@ -451,7 +451,7 @@
452452
453453 $dbw = wfGetDB( DB_MASTER );
454454 $fields = array( 'page_namespace', 'page_title' );
455 - $titleCond = 'page_title like \'' . $dbw->escapeLike( $base ) . "/%%'";
 455+ $titleCond = 'page_title '. $dbw->buildLike( "$base/", $dbw->anyString() );
456456 $conds = array( 'page_namespace' => NS_TRANSLATIONS, $titleCond );
457457 $result = $dbw->select( 'page', $fields, $conds, __METHOD__ );
458458 $this->sectionPages = TitleArray::newFromResult( $result );

Status & tagging log