diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2011-06-22 11:28:20 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2011-06-22 11:28:20 +0200 |
commit | 9db190c7e736ec8d063187d4241b59feaf7dc2d1 (patch) | |
tree | 46d1a0dee7febef5c2d57a9f7b972be16a163b3d /includes/PrefixSearch.php | |
parent | 78677c7bbdcc9739f6c10c75935898a20e1acd9e (diff) |
update to MediaWiki 1.17.0
Diffstat (limited to 'includes/PrefixSearch.php')
-rw-r--r-- | includes/PrefixSearch.php | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/includes/PrefixSearch.php b/includes/PrefixSearch.php index 930b29d4..236e4370 100644 --- a/includes/PrefixSearch.php +++ b/includes/PrefixSearch.php @@ -1,5 +1,4 @@ <?php - /** * PrefixSearch - Handles searching prefixes of titles and finding any page * names that match. Used largely by the OpenSearch implementation. @@ -23,6 +22,7 @@ class PrefixSearch { } $namespaces = self::validateNamespaces( $namespaces ); + // Find a Title which is not an interwiki and is in NS_MAIN $title = Title::newFromText( $search ); if( $title && $title->getInterwiki() == '' ) { $ns = array($title->getNamespace()); @@ -77,6 +77,10 @@ class PrefixSearch { */ protected static function specialSearch( $search, $limit ) { global $wgContLang; + + # normalize searchKey, so aliases with spaces can be found - bug 25675 + $search = str_replace( ' ', '_', $search ); + $searchKey = $wgContLang->caseFold( $search ); // Unlike SpecialPage itself, we want the canonical forms of both @@ -87,9 +91,11 @@ class PrefixSearch { foreach( array_keys( SpecialPage::$mList ) as $page ) { $keys[$wgContLang->caseFold( $page )] = $page; } + foreach( $wgContLang->getSpecialPageAliases() as $page => $aliases ) { - if( !array_key_exists( $page, SpecialPage::$mList ) ) # bug 20885 + if( !array_key_exists( $page, SpecialPage::$mList ) ) {# bug 20885 continue; + } foreach( $aliases as $alias ) { $keys[$wgContLang->caseFold( $alias )] = $alias; @@ -100,12 +106,20 @@ class PrefixSearch { $srchres = array(); foreach( $keys as $pageKey => $page ) { if( $searchKey === '' || strpos( $pageKey, $searchKey ) === 0 ) { - $srchres[] = Title::makeTitle( NS_SPECIAL, $page )->getPrefixedText(); + wfSuppressWarnings(); + // bug 27671: Don't use SpecialPage::getTitleFor() here because it + // localizes its input leading to searches for e.g. Special:All + // returning Spezial:MediaWiki-Systemnachrichten and returning + // Spezial:Alle_Seiten twice when $wgLanguageCode == 'de' + $srchres[] = Title::makeTitleSafe( NS_SPECIAL, $page )->getPrefixedText(); + wfRestoreWarnings(); } + if( count( $srchres ) >= $limit ) { break; } } + return $srchres; } @@ -156,10 +170,12 @@ class PrefixSearch { * Validate an array of numerical namespace indexes * * @param $namespaces Array - * @return Array + * @return Array (default: contains only NS_MAIN) */ protected static function validateNamespaces($namespaces){ global $wgContLang; + + // We will look at each given namespace against wgContLang namespaces $validNamespaces = $wgContLang->getNamespaces(); if( is_array($namespaces) && count($namespaces)>0 ){ $valid = array(); @@ -167,8 +183,9 @@ class PrefixSearch { if( is_numeric($ns) && array_key_exists($ns, $validNamespaces) ) $valid[] = $ns; } - if( count($valid) > 0 ) + if( count($valid) > 0 ) { return $valid; + } } return array( NS_MAIN ); |