Page MenuHomePhabricator

searchbigword-diff.patch

Authored By
bzimport
Nov 21 2014, 9:23 PM
Size
1 KB
Referenced Files
None
Subscribers
None

searchbigword-diff.patch

Index: languages/Language.php
===================================================================
--- languages/Language.php (revision 42655)
+++ languages/Language.php (working copy)
@@ -1519,20 +1519,38 @@
wfProfileIn( __METHOD__ );
if( function_exists( 'mb_strtolower' ) ) {
- $out = preg_replace(
- "/([\\xc0-\\xff][\\x80-\\xbf]*)/e",
- "'U8' . bin2hex( \"$1\" )",
+ $out = preg_replace_callback(
+ "/([\\xc0-\\xff][\\x80-\\xbf]*)/",
+ array( 'self', 'encodeUnicodeCharForSearch' ),
mb_strtolower( $string ) );
} else {
list( , $wikiLowerChars ) = self::getCaseMaps();
- $out = preg_replace(
- "/([\\xc0-\\xff][\\x80-\\xbf]*)/e",
- "'U8' . bin2hex( strtr( \"\$1\", \$wikiLowerChars ) )",
+ $out = preg_replace_callback(
+ "/([\\xc0-\\xff][\\x80-\\xbf]*)/",
+ array( 'self', 'encodeMixedCaseUnicodeForSearch' ),
$string );
}
+
+ ## Pad small words so they get picked up in the index.
+ $out = preg_replace( "/\b\w{1,4}\b/", 'SMALL$0', $out );
+
wfProfileOut( __METHOD__ );
return $out;
}
+
+ private function encodeMixedCaseUnicodeForSearch( $char ) {
+ static $wikiLowerChars = null;
+
+ if (!$wikiLowerChars) {
+ list( , $wikiLowerChars ) = self::getCaseMaps();
+ }
+
+ return 'U8' . bin2hex( strtr( $char, $wikiLowerChars ) );
+ }
+
+ private function encodeUnicodeCharForSearch( $char ) {
+ return 'U8' . bin2hex( $char );
+ }
function convertForSearchResult( $termsArray ) {
# some languages, e.g. Chinese, need to do a conversion

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2748
Default Alt Text
searchbigword-diff.patch (1 KB)

Event Timeline