r101991 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101990‎ | r101991 | r101992 >
Date:13:59, 4 November 2011
Author:nikerabbit
Status:ok
Tags:
Comment:
Bug 21788 - allow fuzzy.php to take optional namespace prefix
Modified paths:
  • /trunk/extensions/Translate/README (modified) (history)
  • /trunk/extensions/Translate/scripts/fuzzy.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/scripts/fuzzy.php
@@ -79,14 +79,6 @@
8080 */
8181 public function __construct( $titles ) {
8282 $this->titles = $titles;
83 -
84 - global $wgTranslateFuzzyBotName;
85 -
86 - if ( !isset( $wgTranslateFuzzyBotName ) ) {
87 - STDERR( "\$wgTranslateFuzzyBotName is not set" );
88 - return;
89 - }
90 -
9183 $this->allclear = true;
9284 }
9385
@@ -111,27 +103,31 @@
112104 global $wgTranslateMessageNamespaces;
113105 $dbr = wfGetDB( DB_SLAVE );
114106
115 - $search_titles = array();
 107+ $search = array();
116108 foreach ( $this->titles as $title ) {
117 - $title = TranslateUtils::title( $title, '' );
118 - $title = str_replace( ' ', '_', $title );
119 - $search_titles[] = 'page_title ' . $dbr->buildLike( $title, $dbr->anyString() );
 109+ $title = Title::newFromText( $title );
 110+ $ns = $title->getNamespace();
 111+ if ( !isset( $search[$ns] ) ) $search[$ns] = array();
 112+ $search[$ns][] = 'page_title' . $dbr->buildLike( $title->getDBKey(), $dbr->anyString() );
120113 }
121114
122 - $condArray = array(
123 - 'page_is_redirect' => 0,
124 - 'page_namespace' => $wgTranslateMessageNamespaces,
 115+ $title_conds = array();
 116+ foreach ( $search as $ns => $names ) {
 117+ if ( $ns == NS_MAIN ) $ns = $wgTranslateMessageNamespaces;
 118+ $titles = $dbr->makeList( $names, LIST_OR );
 119+ $title_conds[] = $dbr->makeList( array( 'page_namespace' => $ns, $titles ), LIST_AND );
 120+ }
 121+
 122+ $conds = array(
125123 'page_latest=rev_id',
126124 'rev_text_id=old_id',
127 - $dbr->makeList( $search_titles, LIST_OR ),
 125+ $dbr->makeList( $title_conds, LIST_OR ),
128126 );
129127
130128 if ( count( $this->skipLanguages ) ) {
131 - $condArray[] = 'substring_index(page_title, \'/\', -1) NOT IN (' . $dbr->makeList( $this->skipLanguages ) . ')';
 129+ $conds = 'substring_index(page_title, \'/\', -1) NOT IN (' . $dbr->makeList( $this->skipLanguages ) . ')';
132130 }
133131
134 - $conds = $dbr->makeList( $condArray, LIST_AND );
135 -
136132 $rows = $dbr->select(
137133 array( 'page', 'revision', 'text' ),
138134 array( 'page_title', 'page_namespace', 'old_text', 'old_flags' ),
Index: trunk/extensions/Translate/README
@@ -29,6 +29,8 @@
3030 http://translatewiki.net/docs/Translate/html/
3131
3232 == Change log ==
 33+* 2011-11-04
 34+- fuzzy.php can now take optional namespace prefix for each message
3335 * 2011-10-30
3436 - The script referenced at 2011-08-26 is now included in the source
3537 - Fixed compatibility with MW 1.17

Status & tagging log