Merge "Fix Postgres support"
[lhc/web/wiklou.git] / includes / page / Article.php
index e7a906d..dd54232 100644 (file)
@@ -19,6 +19,7 @@
  *
  * @file
  */
+use MediaWiki\MediaWikiServices;
 
 /**
  * Class for viewing MediaWiki article and history.
@@ -494,7 +495,7 @@ class Article implements Page {
                $useParserCache = $this->mPage->shouldCheckParserCache( $parserOptions, $oldid );
                wfDebug( 'Article::view using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" );
                if ( $user->getStubThreshold() ) {
-                       $this->getContext()->getStats()->increment( 'pcache_miss_stub' );
+                       MediaWikiServices::getInstance()->getStatsdDataFactory()->increment( 'pcache_miss_stub' );
                }
 
                $this->showRedirectedFromHeader();
@@ -652,7 +653,17 @@ class Article implements Page {
                $this->showViewFooter();
                $this->mPage->doViewUpdates( $user, $oldid );
 
-               $outputPage->addModules( 'mediawiki.action.view.postEdit' );
+               # Load the postEdit module if the user just saved this revision
+               # See also EditPage::setPostEditCookie
+               $request = $this->getContext()->getRequest();
+               $cookieKey = EditPage::POST_EDIT_COOKIE_KEY_PREFIX . $this->getRevIdFetched();
+               $postEdit = $request->getCookie( $cookieKey );
+               if ( $postEdit ) {
+                       # Clear the cookie. This also prevents caching of the response.
+                       $request->response()->clearCookie( $cookieKey );
+                       $outputPage->addJsConfigVars( 'wgPostEdit', $postEdit );
+                       $outputPage->addModules( 'mediawiki.action.view.postEdit' );
+               }
        }
 
        /**
@@ -969,8 +980,8 @@ class Article implements Page {
                }
 
                // Check for cached results
-               $key = wfMemcKey( 'unpatrollable-page', $title->getArticleID() );
-               $cache = ObjectCache::getMainWANInstance();
+               $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
+               $key = $cache->makeKey( 'unpatrollable-page', $title->getArticleID() );
                if ( $cache->get( $key ) ) {
                        return false;
                }
@@ -1110,8 +1121,8 @@ class Article implements Page {
         * @since 1.27
         */
        public static function purgePatrolFooterCache( $articleID ) {
-               $cache = ObjectCache::getMainWANInstance();
-               $cache->delete( wfMemcKey( 'unpatrollable-page', $articleID ) );
+               $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
+               $cache->delete( $cache->makeKey( 'unpatrollable-page', $articleID ) );
        }
 
        /**
@@ -1132,7 +1143,7 @@ class Article implements Page {
                        || $title->getNamespace() == NS_USER_TALK
                ) {
                        $rootPart = explode( '/', $title->getText() )[0];
-                       $user = User::newFromName( $rootPart, false /* allow IP users*/ );
+                       $user = User::newFromName( $rootPart, false /* allow IP users */ );
                        $ip = User::isIP( $rootPart );
                        $block = Block::newFromTarget( $user, $user );
 
@@ -1166,8 +1177,8 @@ class Article implements Page {
                # Show delete and move logs if there were any such events.
                # The logging query can DOS the site when bots/crawlers cause 404 floods,
                # so be careful showing this. 404 pages must be cheap as they are hard to cache.
-               $cache = ObjectCache::getMainStashInstance();
-               $key = wfMemcKey( 'page-recent-delete', md5( $title->getPrefixedText() ) );
+               $cache = MediaWikiServices::getInstance()->getMainObjectStash();
+               $key = $cache->makeKey( 'page-recent-delete', md5( $title->getPrefixedText() ) );
                $loggedIn = $this->getContext()->getUser()->isLoggedIn();
                if ( $loggedIn || $cache->get( $key ) ) {
                        $logTypes = [ 'delete', 'move' ];
@@ -2042,16 +2053,20 @@ class Article implements Page {
        /**
         * Call to WikiPage function for backwards compatibility.
         * @see WikiPage::doPurge
+        * @note In 1.28 (and only 1.28), this took a $flags parameter that
+        *  controlled how much purging was done.
         */
-       public function doPurge( $flags = WikiPage::PURGE_ALL ) {
-               return $this->mPage->doPurge( $flags );
+       public function doPurge() {
+               return $this->mPage->doPurge();
        }
 
        /**
         * Call to WikiPage function for backwards compatibility.
         * @see WikiPage::getLastPurgeTimestamp
+        * @deprecated since 1.29
         */
        public function getLastPurgeTimestamp() {
+               wfDeprecated( __METHOD__, '1.29' );
                return $this->mPage->getLastPurgeTimestamp();
        }