Merge "Rename $usableSkins to $allowedSkins"
[lhc/web/wiklou.git] / includes / Title.php
index d0ac97b..66a6ce5 100644 (file)
@@ -225,7 +225,7 @@ class Title {
         *
         * @param int $id the page_id corresponding to the Title to create
         * @param int $flags use Title::GAID_FOR_UPDATE to use master
-        * @return Title the new object, or NULL on an error
+        * @return Title|null the new object, or NULL on an error
         */
        public static function newFromID( $id, $flags = 0 ) {
                $db = ( $flags & self::GAID_FOR_UPDATE ) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
@@ -757,7 +757,7 @@ class Title {
         */
        public function getTalkNsText() {
                global $wgContLang;
-               return( $wgContLang->getNsText( MWNamespace::getTalk( $this->mNamespace ) ) );
+               return $wgContLang->getNsText( MWNamespace::getTalk( $this->mNamespace ) );
        }
 
        /**
@@ -766,7 +766,7 @@ class Title {
         * @return Bool TRUE or FALSE
         */
        public function canTalk() {
-               return( MWNamespace::canTalk( $this->mNamespace ) );
+               return MWNamespace::canTalk( $this->mNamespace );
        }
 
        /**
@@ -944,7 +944,7 @@ class Title {
         * @return Bool
         */
        public function isConversionTable() {
-               //@todo: ConversionTable should become a separate content model.
+               // @todo ConversionTable should become a separate content model.
 
                return $this->getNamespace() == NS_MEDIAWIKI &&
                        strpos( $this->getText(), 'Conversiontable/' ) === 0;
@@ -1275,10 +1275,10 @@ class Title {
         */
        public function getSubpageText() {
                if ( !MWNamespace::hasSubpages( $this->mNamespace ) ) {
-                       return( $this->mTextform );
+                       return $this->mTextform;
                }
                $parts = explode( '/', $this->mTextform );
-               return( $parts[count( $parts ) - 1] );
+               return $parts[count( $parts ) - 1];
        }
 
        /**
@@ -1318,7 +1318,7 @@ class Title {
        public function getSubpageUrlForm() {
                $text = $this->getSubpageText();
                $text = wfUrlencode( str_replace( ' ', '_', $text ) );
-               return( $text );
+               return $text;
        }
 
        /**
@@ -2046,7 +2046,7 @@ class Title {
                        return $errors;
                }
 
-               global $wgContLang, $wgLang, $wgEmailConfirmToEdit;
+               global $wgEmailConfirmToEdit;
 
                if ( $wgEmailConfirmToEdit && !$user->isEmailConfirmed() ) {
                        $errors[] = array( 'confirmedittext' );
@@ -2056,38 +2056,8 @@ class Title {
                        // Don't block the user from editing their own talk page unless they've been
                        // explicitly blocked from that too.
                } elseif ( $user->isBlocked() && $user->mBlock->prevents( $action ) !== false ) {
-                       $block = $user->getBlock();
-
-                       // This is from OutputPage::blockedPage
-                       // Copied at r23888 by werdna
-
-                       $id = $user->blockedBy();
-                       $reason = $user->blockedFor();
-                       if ( $reason == '' ) {
-                               $reason = wfMessage( 'blockednoreason' )->text();
-                       }
-                       $ip = $user->getRequest()->getIP();
-
-                       if ( is_numeric( $id ) ) {
-                               $name = User::whoIs( $id );
-                       } else {
-                               $name = $id;
-                       }
-
-                       $link = '[[' . $wgContLang->getNsText( NS_USER ) . ":{$name}|{$name}]]";
-                       $blockid = $block->getId();
-                       $blockExpiry = $block->getExpiry();
-                       $blockTimestamp = $wgLang->timeanddate( wfTimestamp( TS_MW, $block->mTimestamp ), true );
-                       if ( $blockExpiry == 'infinity' ) {
-                               $blockExpiry = wfMessage( 'infiniteblock' )->text();
-                       } else {
-                               $blockExpiry = $wgLang->timeanddate( wfTimestamp( TS_MW, $blockExpiry ), true );
-                       }
-
-                       $intended = strval( $block->getTarget() );
-
-                       $errors[] = array( ( $block->mAuto ? 'autoblockedtext' : 'blockedtext' ), $link, $reason, $ip, $name,
-                               $blockid, $blockExpiry, $intended, $blockTimestamp );
+                       // @todo FIXME: Pass the relevant context into this function.
+                       $errors[] = $user->getBlock()->getPermissionsError( RequestContext::getMain() );
                }
 
                return $errors;
@@ -2272,7 +2242,7 @@ class Title {
         * Protect css subpages of user pages: can $wgUser edit
         * this page?
         *
-        * @deprecated in 1.19; will be removed in 1.20. Use getUserPermissionsErrors() instead.
+        * @deprecated in 1.19; use getUserPermissionsErrors() instead.
         * @return Bool
         */
        public function userCanEditCssSubpage() {
@@ -2286,7 +2256,7 @@ class Title {
         * Protect js subpages of user pages: can $wgUser edit
         * this page?
         *
-        * @deprecated in 1.19; will be removed in 1.20. Use getUserPermissionsErrors() instead.
+        * @deprecated in 1.19; use getUserPermissionsErrors() instead.
         * @return Bool
         */
        public function userCanEditJsSubpage() {
@@ -2379,7 +2349,7 @@ class Title {
        /**
         * Update the title protection status
         *
-        * @deprecated in 1.19; will be removed in 1.20. Use WikiPage::doUpdateRestrictions() instead.
+        * @deprecated in 1.19; use WikiPage::doUpdateRestrictions() instead.
         * @param $create_perm String Permission required for creation
         * @param string $reason Reason for protection
         * @param string $expiry Expiry timestamp
@@ -2807,18 +2777,20 @@ class Title {
                        return;
                }
 
+               $method = __METHOD__;
                $dbw = wfGetDB( DB_MASTER );
-               $dbw->delete(
-                       'page_restrictions',
-                       array( 'pr_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ),
-                       __METHOD__
-               );
-
-               $dbw->delete(
-                       'protected_titles',
-                       array( 'pt_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ),
-                       __METHOD__
-               );
+               $dbw->onTransactionIdle( function() use ( $dbw, $method ) {
+                       $dbw->delete(
+                               'page_restrictions',
+                               array( 'pr_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ),
+                               $method
+                       );
+                       $dbw->delete(
+                               'protected_titles',
+                               array( 'pt_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ),
+                               $method
+                       );
+               } );
        }
 
        /**
@@ -3476,6 +3448,7 @@ class Title {
                        }
                }
 
+               wfRunHooks( 'TitleSquidURLs', array( $this, &$urls ) );
                return $urls;
        }
 
@@ -4429,7 +4402,7 @@ class Title {
                        return true;  // any interwiki link might be viewable, for all we know
                }
 
-               switch( $this->mNamespace ) {
+               switch ( $this->mNamespace ) {
                        case NS_MEDIA:
                        case NS_FILE:
                                // file exists, possibly in a foreign repo
@@ -4521,28 +4494,19 @@ class Title {
                        return false;
                }
 
+               $method = __METHOD__;
                $dbw = wfGetDB( DB_MASTER );
                $conds = $this->pageCond();
-               $dbw->onTransactionIdle( function() use ( $dbw, $conds ) {
+               $dbw->onTransactionIdle( function() use ( $dbw, $conds, $method ) {
                        $dbw->update(
                                'page',
                                array( 'page_touched' => $dbw->timestamp() ),
                                $conds,
-                               __METHOD__
+                               $method
                        );
                } );
-               HTMLFileCache::clearFileCache( $this );
 
-               // Clear page info.
-               $revision = WikiPage::factory( $this )->getRevision();
-               if ( $revision !== null ) {
-                       $memcKey = wfMemcKey( 'infoaction', $this->getPrefixedText(), $revision->getId() );
-                       $success = $wgMemc->delete( $memcKey );
-               } else {
-                       $success = true;
-               }
-
-               return $success;
+               return true;
        }
 
        /**