Merge "Use camel case for variable names in Article.php"
[lhc/web/wiklou.git] / includes / page / Article.php
index 0e989d3..c54c692 100644 (file)
@@ -480,7 +480,7 @@ class Article implements Page {
         * page of the given title.
         */
        public function view() {
-               global $wgUseFileCache, $wgUseETag, $wgDebugToolbar;
+               global $wgUseFileCache, $wgUseETag, $wgDebugToolbar, $wgMaxRedirects;
 
                wfProfileIn( __METHOD__ );
 
@@ -542,8 +542,31 @@ class Article implements Page {
                                $outputPage->setETag( $parserCache->getETag( $this, $parserOptions ) );
                        }
 
+                       # Use the greatest of the page's timestamp or the timestamp of any
+                       # redirect in the chain (bug 67849)
+                       $timestamp = $this->mPage->getTouched();
+                       if ( isset( $this->mRedirectedFrom ) ) {
+                               $timestamp = max( $timestamp, $this->mRedirectedFrom->getTouched() );
+
+                               # If there can be more than one redirect in the chain, we have
+                               # to go through the whole chain too in case an intermediate
+                               # redirect was changed.
+                               if ( $wgMaxRedirects > 1 ) {
+                                       $titles = Revision::newFromTitle( $this->mRedirectedFrom )
+                                               ->getContent( Revision::FOR_THIS_USER, $user )
+                                               ->getRedirectChain();
+                                       $thisTitle = $this->getTitle();
+                                       foreach ( $titles as $title ) {
+                                               if ( Title::compare( $title, $thisTitle ) === 0 ) {
+                                                       break;
+                                               }
+                                               $timestamp = max( $timestamp, $title->getTouched() );
+                                       }
+                               }
+                       }
+
                        # Is it client cached?
-                       if ( $outputPage->checkLastModified( $this->mPage->getTouched() ) ) {
+                       if ( $outputPage->checkLastModified( $timestamp ) ) {
                                wfDebug( __METHOD__ . ": done 304\n" );
                                wfProfileOut( __METHOD__ );
 
@@ -680,7 +703,9 @@ class Article implements Page {
                                        $this->mParserOutput = $poolArticleView->getParserOutput();
                                        $outputPage->addParserOutput( $this->mParserOutput );
                                        if ( $content->getRedirectTarget() ) {
-                                               $outputPage->addSubtitle( wfMessage( 'redirectpagesub' )->parse() );
+                                               $outputPage->addSubtitle(
+                                                       "<span id=\"redirectsub\">" . wfMessage( 'redirectpagesub' )->parse() . "</span>"
+                                               );
                                        }
 
                                        # Don't cache a dirty ParserOutput object
@@ -835,7 +860,7 @@ class Article implements Page {
         * @param string $action The action= GET parameter
         * @param ParserOutput|null $pOutput
         * @return array The policy that should be set
-        * @todo: actions other than 'view'
+        * @todo actions other than 'view'
         */
        public function getRobotPolicy( $action, $pOutput = null ) {
                global $wgArticleRobotPolicies, $wgNamespaceRobotPolicies, $wgDefaultRobotPolicy;
@@ -1217,7 +1242,7 @@ class Article implements Page {
 
                $hookResult = wfRunHooks( 'BeforeDisplayNoArticleText', array( $this ) );
 
-               if ( ! $hookResult ) {
+               if ( !$hookResult ) {
                        return;
                }
 
@@ -1245,7 +1270,7 @@ class Article implements Page {
         * If the revision requested for view is deleted, check permissions.
         * Send either an error message or a warning header to the output.
         *
-        * @return bool true if the view is allowed, false if not.
+        * @return bool True if the view is allowed, false if not.
         */
        public function showDeletedRevisionHeader() {
                if ( !$this->mRevision->isDeleted( Revision::DELETED_TEXT ) ) {
@@ -1526,9 +1551,9 @@ class Article implements Page {
                $user = $this->getContext()->getUser();
 
                # Check permissions
-               $permission_errors = $title->getUserPermissionsErrors( 'delete', $user );
-               if ( count( $permission_errors ) ) {
-                       throw new PermissionsError( 'delete', $permission_errors );
+               $permissionErrors = $title->getUserPermissionsErrors( 'delete', $user );
+               if ( count( $permissionErrors ) ) {
+                       throw new PermissionsError( 'delete', $permissionErrors );
                }
 
                # Read-only check...
@@ -1632,11 +1657,12 @@ class Article implements Page {
        public function confirmDelete( $reason ) {
                wfDebug( "Article::confirmDelete\n" );
 
+               $title = $this->getTitle();
                $outputPage = $this->getContext()->getOutput();
-               $outputPage->setPageTitle( wfMessage( 'delete-confirm', $this->getTitle()->getPrefixedText() ) );
-               $outputPage->addBacklinkSubtitle( $this->getTitle() );
+               $outputPage->setPageTitle( wfMessage( 'delete-confirm', $title->getPrefixedText() ) );
+               $outputPage->addBacklinkSubtitle( $title );
                $outputPage->setRobotPolicy( 'noindex,nofollow' );
-               $backlinkCache = $this->getTitle()->getBacklinkCache();
+               $backlinkCache = $title->getBacklinkCache();
                if ( $backlinkCache->hasLinks( 'pagelinks' ) || $backlinkCache->hasLinks( 'templatelinks' ) ) {
                        $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
                                'deleting-backlinks-warning' );
@@ -1658,10 +1684,10 @@ class Article implements Page {
                } else {
                        $suppress = '';
                }
-               $checkWatch = $user->getBoolOption( 'watchdeletion' ) || $user->isWatched( $this->getTitle() );
+               $checkWatch = $user->getBoolOption( 'watchdeletion' ) || $user->isWatched( $title );
 
                $form = Xml::openElement( 'form', array( 'method' => 'post',
-                       'action' => $this->getTitle()->getLocalURL( 'action=delete' ), 'id' => 'deleteconfirm' ) ) .
+                       'action' => $title->getLocalURL( 'action=delete' ), 'id' => 'deleteconfirm' ) ) .
                        Xml::openElement( 'fieldset', array( 'id' => 'mw-delete-table' ) ) .
                        Xml::tags( 'legend', null, wfMessage( 'delete-legend' )->escaped() ) .
                        Xml::openElement( 'table', array( 'id' => 'mw-deleteconfirm-table' ) ) .
@@ -1720,14 +1746,14 @@ class Article implements Page {
                        Xml::closeElement( 'fieldset' ) .
                        Html::hidden(
                                'wpEditToken',
-                               $user->getEditToken( array( 'delete', $this->getTitle()->getPrefixedText() ) )
+                               $user->getEditToken( array( 'delete', $title->getPrefixedText() ) )
                        ) .
                        Xml::closeElement( 'form' );
 
                        if ( $user->isAllowed( 'editinterface' ) ) {
-                               $title = Title::makeTitle( NS_MEDIAWIKI, 'Deletereason-dropdown' );
+                               $dropdownTitle = Title::makeTitle( NS_MEDIAWIKI, 'Deletereason-dropdown' );
                                $link = Linker::link(
-                                       $title,
+                                       $dropdownTitle,
                                        wfMessage( 'delete-edit-reasonlist' )->escaped(),
                                        array(),
                                        array( 'action' => 'edit' )
@@ -1739,9 +1765,7 @@ class Article implements Page {
 
                $deleteLogPage = new LogPage( 'delete' );
                $outputPage->addHTML( Xml::element( 'h2', null, $deleteLogPage->getName()->text() ) );
-               LogEventsList::showLogExtract( $outputPage, 'delete',
-                       $this->getTitle()
-               );
+               LogEventsList::showLogExtract( $outputPage, 'delete', $title );
        }
 
        /**
@@ -1795,7 +1819,7 @@ class Article implements Page {
         * output to the client that is necessary for this request.
         * (that is, it has sent a cached version of the page)
         *
-        * @return bool true if cached version send, false otherwise
+        * @return bool True if cached version send, false otherwise
         */
        protected function tryFileCache() {
                static $called = false;
@@ -1871,7 +1895,7 @@ class Article implements Page {
         * Override the ParserOptions used to render the primary article wikitext.
         *
         * @param ParserOptions $options
-        * @throws MWException if the parser options where already initialized.
+        * @throws MWException If the parser options where already initialized.
         */
        public function setParserOptions( ParserOptions $options ) {
                if ( $this->mParserOptions ) {