Merge "Rewrite pref cleanup script"
[lhc/web/wiklou.git] / includes / page / Article.php
index da8fe88..dadf311 100644 (file)
@@ -75,6 +75,13 @@ class Article implements Page {
        /** @var ParserOutput */
        public $mParserOutput;
 
+       /**
+        * @var bool Whether render() was called. With the way subclasses work
+        * here, there doesn't seem to be any other way to stop calling
+        * OutputPage::enableSectionEditLinks() and still have it work as it did before.
+        */
+       private $disableSectionEditForRender = false;
+
        /**
         * Constructor and clear the article
         * @param Title $title Reference to a Title object.
@@ -469,12 +476,17 @@ class Article implements Page {
                $parserCache = MediaWikiServices::getInstance()->getParserCache();
 
                $parserOptions = $this->getParserOptions();
+               $poOptions = [];
                # Render printable version, use printable version cache
                if ( $outputPage->isPrintable() ) {
                        $parserOptions->setIsPrintable( true );
                        $parserOptions->setEditSection( false );
-               } elseif ( !$this->isCurrent() || !$this->getTitle()->quickUserCan( 'edit', $user ) ) {
+                       $poOptions['enableSectionEditLinks'] = false;
+               } elseif ( $this->disableSectionEditForRender
+                       || !$this->isCurrent() || !$this->getTitle()->quickUserCan( 'edit', $user )
+               ) {
                        $parserOptions->setEditSection( false );
+                       $poOptions['enableSectionEditLinks'] = false;
                }
 
                # Try client and file cache
@@ -533,7 +545,7 @@ class Article implements Page {
                                                        } else {
                                                                wfDebug( __METHOD__ . ": showing parser cache contents\n" );
                                                        }
-                                                       $outputPage->addParserOutput( $this->mParserOutput );
+                                                       $outputPage->addParserOutput( $this->mParserOutput, $poOptions );
                                                        # Ensure that UI elements requiring revision ID have
                                                        # the correct version information.
                                                        $outputPage->setRevisionId( $this->mPage->getLatest() );
@@ -590,14 +602,14 @@ class Article implements Page {
                                                        $outputPage->setRobotPolicy( 'noindex,nofollow' );
 
                                                        $errortext = $error->getWikiText( false, 'view-pool-error' );
-                                                       $outputPage->addWikiText( '<div class="errorbox">' . $errortext . '</div>' );
+                                                       $outputPage->addWikiText( Html::errorBox( $errortext ) );
                                                }
                                                # Connection or timeout error
                                                return;
                                        }
 
                                        $this->mParserOutput = $poolArticleView->getParserOutput();
-                                       $outputPage->addParserOutput( $this->mParserOutput );
+                                       $outputPage->addParserOutput( $this->mParserOutput, $poOptions );
                                        if ( $content->getRedirectTarget() ) {
                                                $outputPage->addSubtitle( "<span id=\"redirectsub\">" .
                                                        $this->getContext()->msg( 'redirectpagesub' )->parse() . "</span>" );
@@ -1179,7 +1191,8 @@ class Article implements Page {
                $cache = MediaWikiServices::getInstance()->getMainObjectStash();
                $key = $cache->makeKey( 'page-recent-delete', md5( $title->getPrefixedText() ) );
                $loggedIn = $this->getContext()->getUser()->isLoggedIn();
-               if ( $loggedIn || $cache->get( $key ) ) {
+               $sessionExists = $this->getContext()->getRequest()->getSession()->isPersistent();
+               if ( $loggedIn || $cache->get( $key ) || $sessionExists ) {
                        $logTypes = [ 'delete', 'move', 'protect' ];
 
                        $dbr = wfGetDB( DB_REPLICA );
@@ -1196,7 +1209,7 @@ class Article implements Page {
                                        'lim' => 10,
                                        'conds' => $conds,
                                        'showIfEmpty' => false,
-                                       'msgKey' => [ $loggedIn
+                                       'msgKey' => [ $loggedIn || $sessionExists
                                                ? 'moveddeleted-notice'
                                                : 'moveddeleted-notice-recent'
                                        ]
@@ -1514,6 +1527,7 @@ class Article implements Page {
                $this->getContext()->getRequest()->response()->header( 'X-Robots-Tag: noindex' );
                $this->getContext()->getOutput()->setArticleBodyOnly( true );
                $this->getContext()->getOutput()->enableSectionEditLinks( false );
+               $this->disableSectionEditForRender = true;
                $this->view();
        }
 
@@ -2638,45 +2652,5 @@ class Article implements Page {
                return $handler->getAutoDeleteReason( $title, $hasHistory );
        }
 
-       /**
-        * @return array
-        *
-        * @deprecated since 1.24, use WikiPage::selectFields() instead
-        */
-       public static function selectFields() {
-               wfDeprecated( __METHOD__, '1.24' );
-               return WikiPage::selectFields();
-       }
-
-       /**
-        * @param Title $title
-        *
-        * @deprecated since 1.24, use WikiPage::onArticleCreate() instead
-        */
-       public static function onArticleCreate( $title ) {
-               wfDeprecated( __METHOD__, '1.24' );
-               WikiPage::onArticleCreate( $title );
-       }
-
-       /**
-        * @param Title $title
-        *
-        * @deprecated since 1.24, use WikiPage::onArticleDelete() instead
-        */
-       public static function onArticleDelete( $title ) {
-               wfDeprecated( __METHOD__, '1.24' );
-               WikiPage::onArticleDelete( $title );
-       }
-
-       /**
-        * @param Title $title
-        *
-        * @deprecated since 1.24, use WikiPage::onArticleEdit() instead
-        */
-       public static function onArticleEdit( $title ) {
-               wfDeprecated( __METHOD__, '1.24' );
-               WikiPage::onArticleEdit( $title );
-       }
-
        // ******
 }