Merge "Remove old styles for #userlogin and #userloginForm"
[lhc/web/wiklou.git] / includes / Title.php
index c726e9d..1d13f4b 100644 (file)
@@ -79,8 +79,8 @@ class Title {
        var $mTitleProtection;            ///< Cached value for getTitleProtection (create protection)
        # Don't change the following default, NS_MAIN is hardcoded in several
        # places.  See bug 696.
+       # Zero except in {{transclusion}} tags
        var $mDefaultNamespace = NS_MAIN; // /< Namespace index when there is no namespace
-                                                                         # Zero except in {{transclusion}} tags
        var $mWatched = null;             // /< Is $wgUser watching this page? null if unfilled, accessed through userIsWatching()
        var $mLength = -1;                // /< The page length, 0 for special pages
        var $mRedirect = null;            // /< Is the article at this title a redirect?
@@ -769,7 +769,12 @@ class Title {
         * @return String DB key
         */
        function getUserCaseDBKey() {
-               return $this->mUserCaseDBKey;
+               if ( !is_null( $this->mUserCaseDBKey ) ) {
+                       return $this->mUserCaseDBKey;
+               } else {
+                       // If created via makeTitle(), $this->mUserCaseDBKey is not set.
+                       return $this->mDbkeyform;
+               }
        }
 
        /**
@@ -1548,9 +1553,9 @@ class Title {
                                $url = false;
                                $matches = array();
 
-                               if ( !empty( $wgActionPaths ) &&
-                                       preg_match( '/^(.*&|)action=([^&]*)(&(.*)|)$/', $query, $matches ) )
-                               {
+                               if ( !empty( $wgActionPaths )
+                                       && preg_match( '/^(.*&|)action=([^&]*)(&(.*)|)$/', $query, $matches )
+                               {
                                        $action = urldecode( $matches[2] );
                                        if ( isset( $wgActionPaths[$action] ) ) {
                                                $query = $matches[1];
@@ -1564,12 +1569,12 @@ class Title {
                                        }
                                }
 
-                               if ( $url === false &&
-                                       $wgVariantArticlePath &&
-                                       $wgContLang->getCode() === $this->getPageLanguage()->getCode() &&
-                                       $this->getPageLanguage()->hasVariants() &&
-                                       preg_match( '/^variant=([^&]*)$/', $query, $matches ) )
-                               {
+                               if ( $url === false
+                                       && $wgVariantArticlePath
+                                       && $wgContLang->getCode() === $this->getPageLanguage()->getCode()
+                                       && $this->getPageLanguage()->hasVariants()
+                                       && preg_match( '/^variant=([^&]*)$/', $query, $matches )
+                               {
                                        $variant = urldecode( $matches[1] );
                                        if ( $this->getPageLanguage()->hasVariant( $variant ) ) {
                                                // Only do the variant replacement if the given variant is a valid
@@ -2125,9 +2130,9 @@ class Title {
                                if ( $title_protection['pt_create_perm'] == 'autoconfirmed' ) {
                                        $title_protection['pt_create_perm'] = 'editsemiprotected'; // B/C
                                }
-                               if ( $title_protection['pt_create_perm'] == '' ||
-                                       !$user->isAllowed( $title_protection['pt_create_perm'] ) )
-                               {
+                               if ( $title_protection['pt_create_perm'] == ''
+                                       || !$user->isAllowed( $title_protection['pt_create_perm'] )
+                               {
                                        $errors[] = array( 'titleprotected', User::whoIs( $title_protection['pt_user'] ), $title_protection['pt_reason'] );
                                }
                        }
@@ -2148,8 +2153,8 @@ class Title {
                        }
                } elseif ( $action == 'delete' ) {
                        if ( $doExpensiveQueries && $wgDeleteRevisionsLimit
-                               && !$this->userCan( 'bigdelete', $user ) && $this->isBigDeletion() )
-                       {
+                               && !$this->userCan( 'bigdelete', $user ) && $this->isBigDeletion()
+                       {
                                $errors[] = array( 'delete-toobig', $wgLang->formatNum( $wgDeleteRevisionsLimit ) );
                        }
                }
@@ -3163,10 +3168,6 @@ class Title {
                $dbkey = preg_replace( '/[ _\xA0\x{1680}\x{180E}\x{2000}-\x{200A}\x{2028}\x{2029}\x{202F}\x{205F}\x{3000}]+/u', '_', $dbkey );
                $dbkey = trim( $dbkey, '_' );
 
-               if ( $dbkey == '' ) {
-                       return false;
-               }
-
                if ( strpos( $dbkey, UTF8_REPLACEMENT ) !== false ) {
                        # Contained illegal UTF-8 sequences or forbidden Unicode chars.
                        return false;
@@ -3176,12 +3177,16 @@ class Title {
 
                # Initial colon indicates main namespace rather than specified default
                # but should not create invalid {ns,title} pairs such as {0,Project:Foo}
-               if ( ':' == $dbkey[0] ) {
+               if ( $dbkey !== '' && ':' == $dbkey[0] ) {
                        $this->mNamespace = NS_MAIN;
                        $dbkey = substr( $dbkey, 1 ); # remove the colon but continue processing
                        $dbkey = trim( $dbkey, '_' ); # remove any subsequent whitespace
                }
 
+               if ( $dbkey == '' ) {
+                       return false;
+               }
+
                # Namespace or interwiki prefix
                $firstPass = true;
                $prefixRegexp = "/^(.+?)_*:_*(.*)$/S";
@@ -3216,8 +3221,8 @@ class Title {
 
                                        # Redundant interwiki prefix to the local wiki
                                        if ( $wgLocalInterwiki !== false
-                                               && 0 == strcasecmp( $this->mInterwiki, $wgLocalInterwiki ) )
-                                       {
+                                               && 0 == strcasecmp( $this->mInterwiki, $wgLocalInterwiki )
+                                       {
                                                if ( $dbkey == '' ) {
                                                        # Can't have an empty self-link
                                                        return false;
@@ -3995,9 +4000,9 @@ class Title {
                        // We don't know whether this function was called before
                        // or after moving the root page, so check both
                        // $this and $nt
-                       if ( $oldSubpage->getArticleID() == $this->getArticleID() ||
-                                       $oldSubpage->getArticleID() == $nt->getArticleID() )
-                       {
+                       if ( $oldSubpage->getArticleID() == $this->getArticleID()
+                               || $oldSubpage->getArticleID() == $nt->getArticleID()
+                       {
                                // When moving a page to a subpage of itself,
                                // don't move it twice
                                continue;
@@ -4696,7 +4701,7 @@ class Title {
         * Get all extant redirects to this Title
         *
         * @param int|Null $ns Single namespace to consider; NULL to consider all namespaces
-        * @return Array of Title redirects to this title
+        * @return Title[] Array of Title redirects to this title
         */
        public function getRedirectsHere( $ns = null ) {
                $redirs = array();