Delete the post-edit cookie using the correct domain
authorSam Smith <git@samsmith.io>
Mon, 31 Mar 2014 14:21:19 +0000 (15:21 +0100)
committerMatthew Flaschen <mflaschen@wikimedia.org>
Thu, 15 May 2014 06:41:33 +0000 (02:41 -0400)
Use the mediawiki.cookie#set to delete the post-edit cookie so that the
correct domain is used.

Bug: 61979
Change-Id: I0cba8d1421f359ff78f3f994af358e9997f27041

includes/EditPage.php
resources/Resources.php
resources/src/mediawiki.action/mediawiki.action.view.postEdit.js

index dac2d55..7be6274 100644 (file)
@@ -1209,8 +1209,6 @@ class EditPage {
         * marked HttpOnly. The JavaScript code converts the cookie to a wgPostEdit config
         * variable.
         *
-        * We use a path of '/' since wgCookiePath is not exposed to JS
-        *
         * If the variable were set on the server, it would be cached, which is unwanted
         * since the post-edit state should only apply to the load right after the save.
         *
@@ -1229,7 +1227,6 @@ class EditPage {
 
                $response = RequestContext::getMain()->getRequest()->response();
                $response->setcookie( $postEditKey, $val, time() + self::POST_EDIT_COOKIE_DURATION, array(
-                       'path' => '/',
                        'httpOnly' => false,
                ) );
        }
index 63e0ccd..a58cfdc 100644 (file)
@@ -994,7 +994,7 @@ return array(
                'scripts' => 'resources/src/mediawiki.action/mediawiki.action.view.postEdit.js',
                'styles' => 'resources/src/mediawiki.action/mediawiki.action.view.postEdit.css',
                'dependencies' => array(
-                       'jquery.cookie',
+                       'mediawiki.cookie',
                        'mediawiki.jqueryMsg'
                ),
                'messages' => array(
index 3419b5a..4d2c47a 100644 (file)
         * @member mw.hook
         */
 
-       var config = mw.config.get( [ 'wgAction', 'wgCookiePrefix', 'wgCurRevisionId' ] ),
+       var config = mw.config.get( [ 'wgAction', 'wgCurRevisionId' ] ),
                // This should match EditPage::POST_EDIT_COOKIE_KEY_PREFIX:
-               cookieKey = config.wgCookiePrefix + 'PostEditRevision' + config.wgCurRevisionId,
-               cookieVal = $.cookie( cookieKey ),
+               cookieKey = 'PostEditRevision' + config.wgCurRevisionId,
+               cookieVal = mw.cookie.get( cookieKey ),
                $div, id;
 
        function showConfirmation( data ) {
@@ -80,7 +80,7 @@
                                mw.user
                        )
                } );
-               $.cookie( cookieKey, null, { path: '/' } );
+               mw.cookie.set( cookieKey, null );
        }
 
 } ( mediaWiki, jQuery ) );