Merge "HTML escape parameter 'text' of hook 'SkinEditSectionLinks'"
[lhc/web/wiklou.git] / includes / search / SearchEngine.php
index 0b29dd7..65a3e6a 100644 (file)
@@ -56,16 +56,16 @@ abstract class SearchEngine {
        /** @var array Feature values */
        protected $features = [];
 
-       /** @const string profile type for completionSearch */
+       /** Profile type for completionSearch */
        const COMPLETION_PROFILE_TYPE = 'completionSearchProfile';
 
-       /** @const string profile type for query independent ranking features */
+       /** Profile type for query independent ranking features */
        const FT_QUERY_INDEP_PROFILE_TYPE = 'fulltextQueryIndepProfile';
 
-       /** @const int flag for legalSearchChars: includes all chars allowed in a search query */
+       /** Integer flag for legalSearchChars: includes all chars allowed in a search query */
        const CHARS_ALL = 1;
 
-       /** @const int flag for legalSearchChars: includes all chars allowed in a search term */
+       /** Integer flag for legalSearchChars: includes all chars allowed in a search term */
        const CHARS_NO_SYNTAX = 2;
 
        /**
@@ -245,6 +245,7 @@ abstract class SearchEngine {
         * search engine
         */
        public function transformSearchTerm( $term ) {
+               wfDeprecated( __METHOD__, '1.34' );
                return $term;
        }
 
@@ -268,25 +269,13 @@ abstract class SearchEngine {
                return $services->newSearchEngine()->getNearMatcher( $config );
        }
 
-       /**
-        * If an exact title match can be found, or a very slightly close match,
-        * return the title. If no match, returns NULL.
-        * @deprecated since 1.27; Use SearchEngine::getNearMatcher()
-        * @param string $searchterm
-        * @return Title
-        */
-       public static function getNearMatch( $searchterm ) {
-               return static::defaultNearMatcher()->getNearMatch( $searchterm );
-       }
-
        /**
         * Get chars legal for search
-        * NOTE: usage as static is deprecated and preserved only as BC measure
         * @param int $type type of search chars (see self::CHARS_ALL
         * and self::CHARS_NO_SYNTAX). Defaults to CHARS_ALL
         * @return string
         */
-       public static function legalSearchChars( $type = self::CHARS_ALL ) {
+       public function legalSearchChars( $type = self::CHARS_ALL ) {
                return "A-Za-z_'.0-9\\x80-\\xFF\\-";
        }
 
@@ -311,7 +300,7 @@ abstract class SearchEngine {
        function setNamespaces( $namespaces ) {
                if ( $namespaces ) {
                        // Filter namespaces to only keep valid ones
-                       $validNs = $this->searchableNamespaces();
+                       $validNs = MediaWikiServices::getInstance()->getSearchEngineConfig()->searchableNamespaces();
                        $namespaces = array_filter( $namespaces, function ( $ns ) use( $validNs ) {
                                return $ns < 0 || isset( $validNs[$ns] );
                        } );
@@ -730,67 +719,6 @@ abstract class SearchEngine {
                return $backend->defaultSearchBackend( $this->namespaces, $search, $this->limit, $this->offset );
        }
 
-       /**
-        * Make a list of searchable namespaces and their canonical names.
-        * @deprecated since 1.27; use SearchEngineConfig::searchableNamespaces()
-        * @return array
-        */
-       public static function searchableNamespaces() {
-               return MediaWikiServices::getInstance()->getSearchEngineConfig()->searchableNamespaces();
-       }
-
-       /**
-        * Extract default namespaces to search from the given user's
-        * settings, returning a list of index numbers.
-        * @deprecated since 1.27; use SearchEngineConfig::userNamespaces()
-        * @param user $user
-        * @return array
-        */
-       public static function userNamespaces( $user ) {
-               return MediaWikiServices::getInstance()->getSearchEngineConfig()->userNamespaces( $user );
-       }
-
-       /**
-        * An array of namespaces indexes to be searched by default
-        * @deprecated since 1.27; use SearchEngineConfig::defaultNamespaces()
-        * @return array
-        */
-       public static function defaultNamespaces() {
-               return MediaWikiServices::getInstance()->getSearchEngineConfig()->defaultNamespaces();
-       }
-
-       /**
-        * Get a list of namespace names useful for showing in tooltips
-        * and preferences
-        * @deprecated since 1.27; use SearchEngineConfig::namespacesAsText()
-        * @param array $namespaces
-        * @return array
-        */
-       public static function namespacesAsText( $namespaces ) {
-               return MediaWikiServices::getInstance()->getSearchEngineConfig()->namespacesAsText( $namespaces );
-       }
-
-       /**
-        * Load up the appropriate search engine class for the currently
-        * active database backend, and return a configured instance.
-        * @deprecated since 1.27; Use SearchEngineFactory::create
-        * @param string $type Type of search backend, if not the default
-        * @return SearchEngine
-        */
-       public static function create( $type = null ) {
-               return MediaWikiServices::getInstance()->getSearchEngineFactory()->create( $type );
-       }
-
-       /**
-        * Return the search engines we support. If only $wgSearchType
-        * is set, it'll be an array of just that one item.
-        * @deprecated since 1.27; use SearchEngineConfig::getSearchTypes()
-        * @return array
-        */
-       public static function getSearchTypes() {
-               return MediaWikiServices::getInstance()->getSearchEngineConfig()->getSearchTypes();
-       }
-
        /**
         * Get a list of supported profiles.
         * Some search engine implementations may expose specific profiles to fine-tune
@@ -814,7 +742,7 @@ abstract class SearchEngine {
         * Create a search field definition.
         * Specific search engines should override this method to create search fields.
         * @param string $name
-        * @param int $type One of the types in SearchIndexField::INDEX_TYPE_*
+        * @param string $type One of the types in SearchIndexField::INDEX_TYPE_*
         * @return SearchIndexField
         * @since 1.28
         */
@@ -894,13 +822,3 @@ abstract class SearchEngine {
                }
        }
 }
-
-/**
- * Dummy class to be used when non-supported Database engine is present.
- * @todo FIXME: Dummy class should probably try something at least mildly useful,
- * such as a LIKE search through titles.
- * @ingroup Search
- */
-class SearchEngineDummy extends SearchEngine {
-       // no-op
-}