Completion search should not change the search query
[lhc/web/wiklou.git] / includes / search / SearchEngine.php
index 3c8fe60..bfcfb59 100644 (file)
@@ -112,11 +112,11 @@ abstract class SearchEngine {
         */
        public function supports( $feature ) {
                switch ( $feature ) {
-               case 'search-update':
-                       return true;
-               case 'title-suffix-filter':
-               default:
-                       return false;
+                       case 'search-update':
+                               return true;
+                       case 'title-suffix-filter':
+                       default:
+                               return false;
                }
        }
 
@@ -406,17 +406,6 @@ abstract class SearchEngine {
                // no-op
        }
 
-       /**
-        * Get OpenSearch suggestion template
-        *
-        * @deprecated since 1.25
-        * @return string
-        */
-       public static function getOpenSearchTemplate() {
-               wfDeprecated( __METHOD__, '1.25' );
-               return ApiOpenSearch::getOpenSearchTemplate( 'application/x-suggestions+json' );
-       }
-
        /**
         * Get the raw text for updating the index from a content object
         * Nicer search backends could possibly do something cooler than
@@ -454,7 +443,9 @@ abstract class SearchEngine {
                $ns = $this->namespaces;
                if ( $title && !$title->isExternal() ) {
                        $ns = [ $title->getNamespace() ];
-                       $search = $title->getText();
+                       if ( $title->getNamespace() !== NS_MAIN ) {
+                               $search = substr( $search, strpos( $search, ':' ) + 1 );
+                       }
                        if ( $ns[0] == NS_MAIN ) {
                                $ns = $this->namespaces; // no explicit prefix, use default namespaces
                                Hooks::run( 'PrefixSearchExtractNamespace', [ &$ns, &$search ] );
@@ -543,7 +534,7 @@ abstract class SearchEngine {
                                $this->setLimitOffset( $fallbackLimit );
                                $fallbackSearchResult = $this->completionSearch( $fbs );
                                $results->appendAll( $fallbackSearchResult );
-                               $fallbackLimit -= count( $fallbackSearchResult );
+                               $fallbackLimit -= $fallbackSearchResult->getSize();
                                if ( $fallbackLimit <= 0 ) {
                                        break;
                                }