if (is_null($title))
return NULL;
- if ( $title->getNamespace() == NS_SPECIAL || $title->exists() ) {
+ if ( $title->getNamespace() == NS_SPECIAL || $title->isExternal()
+ || $title->exists() ) {
return $title;
}
# Now try all lower case (i.e. first letter capitalized)
#
$title = Title::newFromText( $wgContLang->lc( $term ) );
- if ( $title->exists() ) {
+ if ( $title && $title->exists() ) {
return $title;
}
# Now try capitalized string
#
$title = Title::newFromText( $wgContLang->ucwords( $term ) );
- if ( $title->exists() ) {
+ if ( $title && $title->exists() ) {
return $title;
}
# Now try all upper case
#
$title = Title::newFromText( $wgContLang->uc( $term ) );
- if ( $title->exists() ) {
+ if ( $title && $title->exists() ) {
return $title;
}
# Now try Word-Caps-Breaking-At-Word-Breaks, for hyphenated names etc
$title = Title::newFromText( $wgContLang->ucwordbreaks($term) );
- if ( $title->exists() ) {
+ if ( $title && $title->exists() ) {
return $title;
}
- global $wgCapitalLinks, $wgContLang;
- if( !$wgCapitalLinks ) {
- // Catch differs-by-first-letter-case-only
- $title = Title::newFromText( $wgContLang->ucfirst( $term ) );
- if ( $title->exists() ) {
- return $title;
- }
- $title = Title::newFromText( $wgContLang->lcfirst( $term ) );
- if ( $title->exists() ) {
- return $title;
- }
- }
-
// Give hooks a chance at better match variants
$title = null;
if( !wfRunHooks( 'SearchGetNearMatch', array( $term, &$title ) ) ) {
* @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;
}
/**
+ * @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 {
}
/**
+ * 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
}