revert previous stuff. break things :)
[lhc/web/wiklou.git] / includes / Title.php
index 0b58b60..0721c1c 100644 (file)
@@ -393,6 +393,8 @@ class Title {
 
                wfProfileIn( $fname );
 
+               $key = strtolower( $key );
+
                $k = $wgDBname.':interwiki:'.$key;
                if( array_key_exists( $k, $wgTitleInterwikiCache ) ) {
                        wfProfileOut( $fname );
@@ -560,9 +562,19 @@ class Title {
         * @access public
         */
        function getNsText() { 
-               global $wgLang;
-               return $wgLang->getNsText( $this->mNamespace );
+               global $wgContLang;
+               return $wgContLang->getNsText( $this->mNamespace );
        }
+       /**
+        * Get the namespace text of the subject (rather than talk) page
+        * @return string
+        * @access public
+        */
+       function getSubjectNsText() {
+               global $wgContLang;
+               return $wgContLang->getNsText( Namespace::getSubject( $this->mNamespace ) );
+       }
+
        /**
         * Get the interwiki prefix (or null string)
         * @return string
@@ -1321,7 +1333,7 @@ class Title {
 
                                        # Interwiki link
                                        $t = $m[2];
-                                       $this->mInterwiki = $p;
+                                       $this->mInterwiki = strtolower( $p );
 
                                        # Redundant interwiki prefix to the local wiki
                                        if ( 0 == strcasecmp( $this->mInterwiki, $wgLocalInterwiki ) ) {
@@ -1856,7 +1868,7 @@ class Title {
                # Is it a redirect?
                $id  = $nt->getArticleID();
                $obj = $dbw->selectRow( array( 'page', 'revision', 'text'),
-                       array( 'page_is_redirect','old_text' ),
+                       array( 'page_is_redirect','old_text','old_flags' ),
                        array( 'page_id' => $id, 'page_latest=rev_id', 'rev_text_id=old_id' ),
                        $fname, 'FOR UPDATE' );
 
@@ -1864,14 +1876,18 @@ class Title {
                        # Not a redirect
                        return false;
                }
+               $text = Revision::getRevisionText( $obj );
 
                # Does the redirect point to the source?
-               if ( preg_match( "/\\[\\[\\s*([^\\]\\|]*)]]/", $obj->old_text, $m ) ) {
+               if ( preg_match( "/\\[\\[\\s*([^\\]\\|]*)]]/", $text, $m ) ) {
                        $redirTitle = Title::newFromText( $m[1] );
                        if( !is_object( $redirTitle ) ||
                                $redirTitle->getPrefixedDBkey() != $this->getPrefixedDBkey() ) {
                                return false;
                        }
+               } else {
+                       # Fail safe
+                       return false;
                }
 
                # Does the article have a history?