Merge "Revert "Log the reason why revision->getContent() returns null""
[lhc/web/wiklou.git] / includes / search / SearchMySQL.php
index 2c7feeb..8e705c1 100644 (file)
@@ -45,7 +45,7 @@ class SearchMySQL extends SearchDatabase {
        function parseQuery( $filteredText, $fulltext ) {
                global $wgContLang;
 
-               $lc = $this->legalSearchChars(); // Minus format chars
+               $lc = $this->legalSearchChars( self::CHARS_NO_SYNTAX ); // Minus syntax chars (" and *)
                $searchon = '';
                $this->searchTerms = [];
 
@@ -54,9 +54,9 @@ class SearchMySQL extends SearchDatabase {
                if ( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/',
                                $filteredText, $m, PREG_SET_ORDER ) ) {
                        foreach ( $m as $bits ) {
-                               MediaWiki\suppressWarnings();
+                               Wikimedia\suppressWarnings();
                                list( /* all */, $modifier, $term, $nonQuoted, $wildcard ) = $bits;
-                               MediaWiki\restoreWarnings();
+                               Wikimedia\restoreWarnings();
 
                                if ( $nonQuoted != '' ) {
                                        $term = $nonQuoted;
@@ -149,8 +149,13 @@ class SearchMySQL extends SearchDatabase {
                return $regex;
        }
 
-       public function legalSearchCharsForUpdate() {
-               return "\"*" . parent::legalSearchCharsForUpdate();
+       public static function legalSearchChars( $type = self::CHARS_ALL ) {
+               $searchChars = parent::legalSearchChars( $type );
+               if ( $type === self::CHARS_ALL ) {
+                       // " for phrase, * for wildcard
+                       $searchChars = "\"*" . $searchChars;
+               }
+               return $searchChars;
        }
 
        /**
@@ -204,16 +209,16 @@ class SearchMySQL extends SearchDatabase {
 
        public function supports( $feature ) {
                switch ( $feature ) {
-               case 'title-suffix-filter':
-                       return true;
-               default:
-                       return parent::supports( $feature );
+                       case 'title-suffix-filter':
+                               return true;
+                       default:
+                               return parent::supports( $feature );
                }
        }
 
        /**
         * Add special conditions
-        * @param array $query
+        * @param array &$query
         * @since 1.18
         */
        protected function queryFeatures( &$query ) {
@@ -226,7 +231,7 @@ class SearchMySQL extends SearchDatabase {
 
        /**
         * Add namespace conditions
-        * @param array $query
+        * @param array &$query
         * @since 1.18 (changed)
         */
        function queryNamespaces( &$query ) {
@@ -240,7 +245,7 @@ class SearchMySQL extends SearchDatabase {
 
        /**
         * Add limit options
-        * @param array $query
+        * @param array &$query
         * @since 1.18
         */
        protected function limitResult( &$query ) {