Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3178
searchbigword-diff.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
•
bzimport
Nov 21 2014, 9:23 PM
2014-11-21 21:23:21 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
searchbigword-diff.patch
View Options
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
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2748
Default Alt Text
searchbigword-diff.patch (1 KB)
Attached To
Mode
T9726: Searches less than 4 characters long don't work
Attached
Detach File
Event Timeline
Log In to Comment