Merge "SpecialUserrights: Use session data instead of URL parameter for success"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 15 Dec 2016 10:16:01 +0000 (10:16 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 15 Dec 2016 10:16:01 +0000 (10:16 +0000)
1  2 
includes/specials/SpecialUserrights.php

@@@ -76,6 -76,7 +76,7 @@@ class UserrightsPage extends SpecialPag
        public function execute( $par ) {
                $user = $this->getUser();
                $request = $this->getRequest();
+               $session = $request->getSession();
                $out = $this->getOutput();
  
                if ( $par !== null ) {
                        $this->mTarget = trim( $this->mTarget );
                }
  
 +              if ( $this->mTarget !== null && User::getCanonicalName( $this->mTarget ) === $user->getName() ) {
 +                      $this->isself = true;
 +              }
 +
                $fetchedStatus = $this->fetchUser( $this->mTarget, true );
                if ( $fetchedStatus->isOK() ) {
                        $this->mFetchedUser = $fetchedStatus->value;
                }
  
                // 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(
                                        $targetUser
                                );
  
+                               // Set session data for the success message
+                               $session->set( 'specialUserrightsSaveSuccess', 1 );
                                $out->redirect( $this->getSuccessURL() );
  
                                return;
        }
  
        function getSuccessURL() {
-               return $this->getPageTitle( $this->mTarget )->getFullURL( [ 'success' => 1 ] );
+               return $this->getPageTitle( $this->mTarget )->getFullURL();
        }
  
        /**
         * @param bool $writing
         * @return Status
         */
 -      public function fetchUser( $username, $writing ) {
 +      public function fetchUser( $username, $writing = true ) {
                $parts = explode( $this->getConfig()->get( 'UserrightsInterwikiDelimiter' ), $username );
                if ( count( $parts ) < 2 ) {
                        $name = trim( $username );
                        Xml::element(
                                'legend',
                                [],
 -                              $this->msg( 'userrights-editusergroup', $user->getName() )->text()
 +                              $this->msg(
 +                                      $canChangeAny ? 'userrights-editusergroup' : 'userrights-viewusergroup',
 +                                      $user->getName()
 +                              )->text()
                        ) .
 -                      $this->msg( 'editinguser' )->params( wfEscapeWikiText( $user->getName() ) )
 +                      $this->msg(
 +                              $canChangeAny ? 'editinguser' : 'viewinguserrights'
 +                      )->params( wfEscapeWikiText( $user->getName() ) )
                                ->rawParams( $userToolLinks )->parse()
                );
                if ( $canChangeAny ) {