From aaf794947a77ab0edb0e8ae21f32b85fdc61d87d Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Fri, 25 Jul 2008 23:12:27 +0000 Subject: [PATCH] Remove a bit of useless $wgCapitalLinks logic, all these code paths lead through Title::secureAndSpit() which handles initial-character-capitalization. *In SearchEngine's case, it gets caught every time further up the page (it never even reaches the upper/lower casing of only first character part) *PrefixSearch eventually sends it through ApiQueryBase::titleToKey() *AjaxFunctions immediately sends it to Title::newFromText() --- includes/AjaxFunctions.php | 4 +--- includes/PrefixSearch.php | 10 +++------- includes/SearchEngine.php | 13 ------------- 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/includes/AjaxFunctions.php b/includes/AjaxFunctions.php index 9daca9e5d1..327dead51f 100644 --- a/includes/AjaxFunctions.php +++ b/includes/AjaxFunctions.php @@ -75,15 +75,13 @@ function code2utf($num){ define( 'AJAX_SEARCH_VERSION', 2 ); //AJAX search cache version function wfSajaxSearch( $term ) { - global $wgContLang, $wgUser, $wgCapitalLinks, $wgMemc; + global $wgContLang, $wgUser, $wgMemc; $limit = 16; $sk = $wgUser->getSkin(); $output = ''; $term = trim( $term ); $term = $wgContLang->checkTitleEncoding( $wgContLang->recodeInput( js_unescape( $term ) ) ); - if ( $wgCapitalLinks ) - $term = $wgContLang->ucfirst( $term ); $term_title = Title::newFromText( $term ); $memckey = $term_title ? wfMemcKey( 'ajaxsearch', md5( $term_title->getFullText() ) ) : wfMemcKey( 'ajaxsearch', md5( $term ) ); diff --git a/includes/PrefixSearch.php b/includes/PrefixSearch.php index a3ff05e25c..17f8ec1e18 100644 --- a/includes/PrefixSearch.php +++ b/includes/PrefixSearch.php @@ -96,7 +96,9 @@ class PrefixSearch { /** * Unless overridden by PrefixSearchBackend hook... - * This is case-sensitive except the first letter (per $wgCapitalLinks) + * This is case-sensitive (First character may + * be automatically capitalized by Title::secureAndSpit() + * later on depending on $wgCapitalLinks) * * @param array $namespaces Namespaces to search in * @param string $search term @@ -104,12 +106,6 @@ class PrefixSearch { * @return array of title strings */ protected static function defaultSearchBackend( $namespaces, $search, $limit ) { - global $wgCapitalLinks, $wgContLang; - - if( $wgCapitalLinks ) { - $search = $wgContLang->ucfirst( $search ); - } - $ns = array_shift($namespaces); // support only one namespace if( in_array(NS_MAIN,$namespaces)) $ns = NS_MAIN; // if searching on many always default to main diff --git a/includes/SearchEngine.php b/includes/SearchEngine.php index 04fa906a00..fae5edca9e 100644 --- a/includes/SearchEngine.php +++ b/includes/SearchEngine.php @@ -98,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 ) ) ) { -- 2.20.1