(bug 15543) fix for r38139: don't include $wgUser->mTouched and smaxage=0 in query...
[lhc/web/wiklou.git] / includes / SearchEngine.php
index 50231d3..72e0635 100644 (file)
@@ -66,7 +66,8 @@ class SearchEngine {
                        if (is_null($title))
                                return NULL;
 
-                       if ( $title->getNamespace() == NS_SPECIAL || $title->exists() ) {
+                       if ( $title->getNamespace() == NS_SPECIAL || $title->isExternal() 
+                            || $title->exists() ) {
                                return $title;
                        }
 
@@ -97,19 +98,6 @@ class SearchEngine {
                                return $title;
                        }
 
-                       global $wgCapitalLinks, $wgContLang;
-                       if( !$wgCapitalLinks ) {
-                               // Catch differs-by-first-letter-case-only
-                               $title = Title::newFromText( $wgContLang->ucfirst( $term ) );
-                               if ( $title && $title->exists() ) {
-                                       return $title;
-                               }
-                               $title = Title::newFromText( $wgContLang->lcfirst( $term ) );
-                               if ( $title && $title->exists() ) {
-                                       return $title;
-                               }
-                       }
-
                        // Give hooks a chance at better match variants
                        $title = null;
                        if( !wfRunHooks( 'SearchGetNearMatch', array( $term, &$title ) ) ) {
@@ -292,19 +280,14 @@ class SearchEngine {
         * @return SearchEngine
         */
        public static function create() {
-               global $wgDBtype, $wgSearchType;
+               global $wgSearchType;
+               $dbr = wfGetDB( DB_SLAVE );
                if( $wgSearchType ) {
                        $class = $wgSearchType;
-               } elseif( $wgDBtype == 'mysql' ) {
-                       $class = 'SearchMySQL';
-               } else if ( $wgDBtype == 'postgres' ) {
-                       $class = 'SearchPostgres';
-               } else if ( $wgDBtype == 'oracle' ) {
-                       $class = 'SearchOracle';
                } else {
-                       $class = 'SearchEngineDummy';
+                       $class = $dbr->getSearchEngine();
                }
-               $search = new $class( wfGetDB( DB_SLAVE ) );
+               $search = new $class( $dbr );
                $search->setLimitOffset(0,0);
                return $search;
        }
@@ -493,6 +476,9 @@ class SearchResultTooMany {
 
 
 /**
+ * @fixme This class is horribly factored. It would probably be better to have
+ * a useful base class to which you pass some standard information, then let
+ * the fancy self-highlighters extend that.
  * @ingroup Search
  */
 class SearchResult {
@@ -1138,16 +1124,11 @@ class SearchHighlighter {
 }
 
 /**
+ * Dummy class to be used when non-supported Database engine is present.
+ * @fixme Dummy class should probably try something at least mildly useful,
+ * such as a LIKE search through titles.
  * @ingroup Search
  */
-class SearchEngineDummy {
-       function search( $term ) {
-               return null;
-       }
-       function setLimitOffset($l, $o) {}
-       function legalSearchChars() {}
-       function update() {}
-       function setnamespaces() {}
-       function searchtitle() {}
-       function searchtext() {}
+class SearchEngineDummy extends SearchEngine {
+       // no-op
 }