From 845262071171c5a7f5e712d467e1df9bf77beb4d Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Fri, 5 Dec 2008 18:16:01 +0000 Subject: [PATCH] Use boolean searching with '?' char --- includes/SearchEngine.php | 2 +- includes/SearchMySQL.php | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/includes/SearchEngine.php b/includes/SearchEngine.php index 66e8d9bb8a..6aa726c8c2 100644 --- a/includes/SearchEngine.php +++ b/includes/SearchEngine.php @@ -150,7 +150,7 @@ class SearchEngine { } public static function legalSearchChars() { - return "A-Za-z_'0-9\\x80-\\xFF\\-"; + return "A-Za-z_'0-9\\x80-\\xFF\\-\\?"; } /** diff --git a/includes/SearchMySQL.php b/includes/SearchMySQL.php index f9b71c8ecd..6f2b3388a5 100644 --- a/includes/SearchMySQL.php +++ b/includes/SearchMySQL.php @@ -43,12 +43,18 @@ class SearchMySQL extends SearchEngine { # FIXME: This doesn't handle parenthetical expressions. $m = array(); - if( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', - $filteredText, $m, PREG_SET_ORDER ) ) { + if( preg_match_all( '/([-+<>?~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', + $filteredText, $m, PREG_SET_ORDER ) ) + { foreach( $m as $terms ) { if( $searchon !== '' ) $searchon .= ' '; - if( $this->strictMatching && ($terms[1] == '') ) { - $terms[1] = '+'; + if( $this->strictMatching ) { + // '' means AND while ? means OR to the user + if( $terms[1] == '' ) { + $terms[1] = '+'; + } else if( $terms[1] == '?' ) { + $terms[1] = ''; + } } $searchon .= $terms[1] . $wgContLang->stripForSearch( $terms[2] ); if( !empty( $terms[3] ) ) { -- 2.20.1