$t->mDefaultNamespace = $defaultNamespace;
wfProfileOut( $fname );
+ if ( !is_object( $t ) ) {
+ var_dump( debug_backtrace() );
+ }
if( $t->secureAndSplit() ) {
return $t;
} else {
# The URL contains $1, which is replaced by the title
function getInterwikiLink( $key )
{
- global $wgMemc, $wgDBname, $title_interwiki_cache;
+ global $wgMemc, $wgDBname;
+ static $title_interwiki_cache = array();
+
$k = "$wgDBname:interwiki:$key";
if( array_key_exists( $k, $title_interwiki_cache ) )
#
/* private */ function secureAndSplit()
{
- global $wgLang, $wgLocalInterwiki;
+ global $wgLang, $wgLocalInterwiki, $wgCapitalLinks;
$fname = "Title::secureAndSplit";
wfProfileIn( $fname );
if ( preg_match( "/^((?:i|x|[a-z]{2,3})(?:-[a-z0-9]+)?|[A-Za-z0-9_\\x80-\\xff]+?)_*:_*(.*)$/", $t, $m ) ) {
#$p = strtolower( $m[1] );
$p = $m[1];
- if ( $ns = $wgLang->getNsIndex( strtolower( $p ) )) {
+ $lowerNs = strtolower( $p );
+ if ( $ns = Namespace::getCanonicalIndex( $lowerNs ) ) {
+ # Canonical namespace
+ $t = $m[2];
+ $this->mNamespace = $ns;
+ } elseif ( $ns = $wgLang->getNsIndex( $lowerNs )) {
# Ordinary namespace
$t = $m[2];
$this->mNamespace = $ns;
}
# Initial capital letter
- if( $this->mInterwiki == "") $t = $wgLang->ucfirst( $r );
-
+ if( $wgCapitalLinks && $this->mInterwiki == "") {
+ $t = $wgLang->ucfirst( $r );
+ }
+
# Fill fields
$this->mDbkeyform = $t;
$this->mUrlform = wfUrlencode( $t );