Clear postEdit cookie on server-side
[lhc/web/wiklou.git] / includes / page / Article.php
index 6067649..3c767f5 100644 (file)
@@ -653,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' );
+               }
        }
 
        /**
@@ -1133,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 );