diff options
author | Fomafix <fomafix@googlemail.com> | 2016-01-09 22:41:46 +0000 |
---|---|---|
committer | [[mw:User:Fomafix]] <gerritpatchuploader@gmail.com> | 2016-01-09 22:41:46 +0000 |
commit | 486bc2073a09adfa6f6ff8279a31bc4b87eb452d (patch) | |
tree | 8ad1e74fe99b4e0a8b6ae096f72ee3480fc87764 | |
parent | 381a6ce691840437c6a449fe52bfd6dacb80af2d (diff) | |
download | mediawikicore-486bc2073a09adfa6f6ff8279a31bc4b87eb452d.tar.gz mediawikicore-486bc2073a09adfa6f6ff8279a31bc4b87eb452d.zip |
Preferences: Use session data instead of URL parameter for success
The session data gets set in the POST and gets deleted in the GET.
This change avoids changing the URL for the success message.
A reload of the page does not show the success message again.
The URL manipulation in mediawiki.special.preferences.js is superfluous.
Bug: T26700
Change-Id: I1c2b011e7a66b2b9379dd4a3fdcc6f978dd43b52
-rw-r--r-- | includes/Preferences.php | 8 | ||||
-rw-r--r-- | includes/specials/SpecialPreferences.php | 10 | ||||
-rw-r--r-- | resources/src/mediawiki.special/mediawiki.special.preferences.js | 5 |
3 files changed, 14 insertions, 9 deletions
diff --git a/includes/Preferences.php b/includes/Preferences.php index ad25fa8d9129..5f37e3f75d24 100644 --- a/includes/Preferences.php +++ b/includes/Preferences.php @@ -1470,7 +1470,7 @@ class Preferences { $res = self::tryFormSubmit( $formData, $form ); if ( $res ) { - $urlOptions = array( 'success' => 1 ); + $urlOptions = array(); if ( $res === 'eauth' ) { $urlOptions['eauth'] = 1; @@ -1480,7 +1480,11 @@ class Preferences { $url = $form->getTitle()->getFullURL( $urlOptions ); - $form->getContext()->getOutput()->redirect( $url ); + $context = $form->getContext(); + // Set session data for the success message + $context->getRequest()->setSessionData( 'specialPreferencesSaveSuccess', 1 ); + + $context->getOutput()->redirect( $url ); } return Status::newGood(); diff --git a/includes/specials/SpecialPreferences.php b/includes/specials/SpecialPreferences.php index b45946f10f6a..3fa5fd526cb2 100644 --- a/includes/specials/SpecialPreferences.php +++ b/includes/specials/SpecialPreferences.php @@ -49,7 +49,11 @@ class SpecialPreferences extends SpecialPage { $out->addModules( 'mediawiki.special.preferences' ); $out->addModuleStyles( 'mediawiki.special.preferences.styles' ); - if ( $this->getRequest()->getCheck( 'success' ) ) { + $request = $this->getRequest(); + if ( $request->getSessionData( 'specialPreferencesSaveSuccess' ) ) { + // Remove session data for the success message + $request->setSessionData( 'specialPreferencesSaveSuccess', null ); + $out->wrapWikiMsg( Html::rawElement( 'div', @@ -132,8 +136,10 @@ class SpecialPreferences extends SpecialPage { $user->resetOptions( 'all', $this->getContext() ); $user->saveSettings(); - $url = $this->getPageTitle()->getFullURL( 'success' ); + // Set session data for the success message + $this->getRequest()->setSessionData( 'specialPreferencesSaveSuccess', 1 ); + $url = $this->getPageTitle()->getFullURL(); $this->getOutput()->redirect( $url ); return true; diff --git a/resources/src/mediawiki.special/mediawiki.special.preferences.js b/resources/src/mediawiki.special/mediawiki.special.preferences.js index c2b9a4ff1d0a..92064a698c13 100644 --- a/resources/src/mediawiki.special/mediawiki.special.preferences.js +++ b/resources/src/mediawiki.special/mediawiki.special.preferences.js @@ -94,11 +94,6 @@ notif = null; } } ); - - // Remove now-unnecessary success=1 querystring to prevent reappearance of notification on reload - if ( history.replaceState ) { - history.replaceState( {}, document.title, location.href.replace( /&?success=1/, '' ) ); - } } } |