r51659 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51658‎ | r51659 | r51660 >
Date:19:19, 9 June 2009
Author:philip
Status:ok
Tags:
Comment:
[[Special:Search]] now could search terms in all variant-forms. ONLY apply on wikis with LanguageConverter.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/SearchIBM_DB2.php (modified) (history)
  • /trunk/phase3/includes/SearchMySQL.php (modified) (history)
  • /trunk/phase3/includes/SearchOracle.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SearchOracle.php
@@ -159,7 +159,17 @@
160160 if (preg_match_all('/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/',
161161 $filteredText, $m, PREG_SET_ORDER)) {
162162 foreach($m as $terms) {
163 - $q[] = $terms[1] . $wgContLang->stripForSearch($terms[2]);
 163+
 164+ // Search terms in all variant forms, only
 165+ // apply on wiki with LanguageConverter
 166+ $temp_terms = $wgContLang->autoConvertToAllVariants( $terms[2] );
 167+ if( is_array( $temp_terms )) {
 168+ $temp_terms = array_unique( array_values( $temp_terms ));
 169+ foreach( $temp_terms as $t )
 170+ $q[] = $terms[1] . $wgContLang->stripForSearch( $t );
 171+ }
 172+ else
 173+ $q[] = $terms[1] . $wgContLang->stripForSearch( $terms[2] );
164174
165175 if (!empty($terms[3])) {
166176 $regexp = preg_quote( $terms[3], '/' );
Index: trunk/phase3/includes/SearchIBM_DB2.php
@@ -151,8 +151,18 @@
152152 if (preg_match_all('/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/',
153153 $filteredText, $m, PREG_SET_ORDER)) {
154154 foreach($m as $terms) {
155 - $q[] = $terms[1] . $wgContLang->stripForSearch($terms[2]);
156155
 156+ // Search terms in all variant forms, only
 157+ // apply on wiki with LanguageConverter
 158+ $temp_terms = $wgContLang->autoConvertToAllVariants( $terms[2] );
 159+ if( is_array( $temp_terms )) {
 160+ $temp_terms = array_unique( array_values( $temp_terms ));
 161+ foreach( $temp_terms as $t )
 162+ $q[] = $terms[1] . $wgContLang->stripForSearch( $t );
 163+ }
 164+ else
 165+ $q[] = $terms[1] . $wgContLang->stripForSearch( $terms[2] );
 166+
157167 if (!empty($terms[3])) {
158168 $regexp = preg_quote( $terms[3], '/' );
159169 if ($terms[4])
Index: trunk/phase3/includes/SearchMySQL.php
@@ -53,7 +53,16 @@
5454 if( $this->strictMatching && ($terms[1] == '') ) {
5555 $terms[1] = '+';
5656 }
57 - $searchon .= $terms[1] . $wgContLang->stripForSearch( $terms[2] );
 57+ // Search terms in all variant forms, only
 58+ // apply on wiki with LanguageConverter
 59+ $temp_terms = $wgContLang->autoConvertToAllVariants( $terms[2] );
 60+ if( is_array( $temp_terms )) {
 61+ $temp_terms = array_unique( array_values( $temp_terms ));
 62+ foreach( $temp_terms as $t )
 63+ $searchon .= $terms[1] . $wgContLang->stripForSearch( $t ) . ' ';
 64+ }
 65+ else
 66+ $searchon .= $terms[1] . $wgContLang->stripForSearch( $terms[2] );
5867 if( !empty( $terms[3] ) ) {
5968 // Match individual terms in result highlighting...
6069 $regexp = preg_quote( $terms[3], '/' );
@@ -259,4 +268,4 @@
260269 function free() {
261270 $this->mResultSet->free();
262271 }
263 -}
 272+}
\ No newline at end of file
Index: trunk/phase3/RELEASE-NOTES
@@ -81,6 +81,8 @@
8282 'recentchangeslinked-toolbox' were added to allow more fine grained
8383 customisation of the user interface
8484 * DISPLAYTITLE now accepts a limited amount of wiki markup (the single-quote items)
 85+* Special:Search now could search terms in all variant-forms. ONLY apply on
 86+ wikis with LanguageConverter
8587
8688 === Bug fixes in 1.16 ===
8789

Status & tagging log