Page MenuHomePhabricator

searchpg_patch

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

searchpg_patch

This document is not UTF8. It was detected as Shift JIS and converted to UTF8 for display.
Index: includes/SearchPostgres.php
===================================================================
--- includes/SearchPostgres.php (r騅ision 19893)
+++ includes/SearchPostgres.php (copie de travail)
@@ -55,6 +55,7 @@
global $wgContLang;
$lc = SearchEngine::legalSearchChars();
$searchon = '';
+ $searchconst = '';
$this->searchTerms = array();
# FIXME: This doesn't handle parenthetical expressions.
@@ -62,11 +63,15 @@
if( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/',
$filteredText, $m, PREG_SET_ORDER ) ) {
foreach( $m as $terms ) {
- if( $searchon !== '' ) $searchon .= ' ';
- if($terms[1] == '') {
- $terms[1] = '+';
- }
- $searchon .= $terms[1] . $wgContLang->stripForSearch( $terms[2] );
+ switch ($terms[1]) {
+ # FIXME : what those operators usually do ?
+// case '<': break;
+// case '>': break;
+// case '~': break;
+ case '-': $searchconst.= '&!' . $wgContLang->stripForSearch( $terms[2] ); break;
+ case '+': $searchconst.= '&' . $wgContLang->stripForSearch( $terms[2] ); break;
+ default : $searchon.= '|' . $wgContLang->stripForSearch( $terms[2] );
+ }
if( !empty( $terms[3] ) ) {
$regexp = preg_quote( $terms[3], '/' );
if( $terms[4] ) $regexp .= "[0-9A-Za-z_]+";
@@ -80,8 +85,10 @@
} else {
wfDebug( "Can't understand search query '{$this->filteredText}'\n" );
}
-
- $searchon = preg_replace('/!/','\\!',$searchon);
+ if (substr_count($searchon,'|')==1) {
+ $searchon = str_replace ('|','&',$searchon);
+ }
+ $searchon = substr($searchconst . $searchon, 1) ;
$searchon = preg_replace('/(\s+)/','&',$searchon);
$searchon = $this->db->strencode( $searchon );
return $searchon;

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3117
Default Alt Text
searchpg_patch (1 KB)

Event Timeline