1) when autosummaries are mixed with human-written ones, insert separators
[lhc/web/wiklou.git] / includes / Title.php
index 86a3f7d..94ef83e 100644 (file)
@@ -85,6 +85,9 @@ class Title {
         $t->mDefaultNamespace = $defaultNamespace;
         
                wfProfileOut( $fname );
+               if ( !is_object( $t ) ) {
+                       var_dump( debug_backtrace() );
+               }
                if( $t->secureAndSplit() ) {
                        return $t;
                } else {
@@ -235,7 +238,9 @@ class Title {
        # 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 ) )
@@ -578,7 +583,7 @@ class Title {
        #
        /* private */ function secureAndSplit()
        {
-               global $wgLang, $wgLocalInterwiki;
+               global $wgLang, $wgLocalInterwiki, $wgCapitalLinks;
                $fname = "Title::secureAndSplit";
                wfProfileIn( $fname );
                
@@ -626,7 +631,12 @@ class Title {
                        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;
@@ -672,8 +682,10 @@ class Title {
                }
 
                # 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 );