SpecialUserrights: Use session data instead of URL parameter for success
authorFomafix <fomafix@googlemail.com>
Sun, 27 Dec 2015 16:46:17 +0000 (16:46 +0000)
committerFomafix <fomafix@googlemail.com>
Sat, 26 Nov 2016 10:07:06 +0000 (11:07 +0100)
The session data gets set in the POST and gets removed 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.

Bug: T60492
Change-Id: Iac8d4e6adc4dc93a3da645485f18770fcd2b3872

includes/specials/SpecialUserrights.php

index 6ded6d9..89dcdad 100644 (file)
@@ -76,6 +76,7 @@ class UserrightsPage extends SpecialPage {
        public function execute( $par ) {
                $user = $this->getUser();
                $request = $this->getRequest();
+               $session = $request->getSession();
                $out = $this->getOutput();
 
                if ( $par !== null ) {
@@ -99,7 +100,13 @@ class UserrightsPage extends SpecialPage {
                }
 
                // show a successbox, if the user rights was saved successfully
-               if ( $request->getCheck( 'success' ) && $this->mFetchedUser !== null ) {
+               if (
+                       $session->get( 'specialUserrightsSaveSuccess' ) &&
+                       $this->mFetchedUser !== null
+               ) {
+                       // Remove session data for the success message
+                       $session->remove( 'specialUserrightsSaveSuccess' );
+
                        $out->addModules( [ 'mediawiki.special.userrights' ] );
                        $out->addModuleStyles( 'mediawiki.notification.convertmessagebox.styles' );
                        $out->addHTML(
@@ -167,6 +174,9 @@ class UserrightsPage extends SpecialPage {
                                        $targetUser
                                );
 
+                               // Set session data for the success message
+                               $session->set( 'specialUserrightsSaveSuccess', 1 );
+
                                $out->redirect( $this->getSuccessURL() );
 
                                return;
@@ -180,7 +190,7 @@ class UserrightsPage extends SpecialPage {
        }
 
        function getSuccessURL() {
-               return $this->getPageTitle( $this->mTarget )->getFullURL( [ 'success' => 1 ] );
+               return $this->getPageTitle( $this->mTarget )->getFullURL();
        }
 
        /**