Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/316705

Change subject: FormSpecialPage: Only add redirectparams for POST forms
......................................................................

FormSpecialPage: Only add redirectparams for POST forms

If the form is submitted via GET, using redirectparams doesn't make
sense, and you end up with redirect params being included in the GET
query string. And then if the form is submitted again, the
redirectparams include the previous redirectparams, and so on.

Change-Id: I9bc930e5dca557571b4658444fea6aec59c5797a
---
M includes/specialpage/FormSpecialPage.php
1 file changed, 6 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/05/316705/1

diff --git a/includes/specialpage/FormSpecialPage.php 
b/includes/specialpage/FormSpecialPage.php
index c28c456..6867f8a 100644
--- a/includes/specialpage/FormSpecialPage.php
+++ b/includes/specialpage/FormSpecialPage.php
@@ -107,14 +107,16 @@
                        $form->addHeaderText( $headerMsg->parseAsBlock() );
                }
 
-               // Retain query parameters (uselang etc)
-               $params = array_diff_key(
-                       $this->getRequest()->getQueryValues(), [ 'title' => 
null ] );
-               $form->addHiddenField( 'redirectparams', wfArrayToCgi( $params 
) );
 
                $form->addPreText( $this->preText() );
                $form->addPostText( $this->postText() );
                $this->alterForm( $form );
+               if ( $form->getMethod() == 'post' ) {
+                       // Retain query parameters (uselang etc) on POST 
requests
+                       $params = array_diff_key(
+                               $this->getRequest()->getQueryValues(), [ 
'title' => null ] );
+                       $form->addHiddenField( 'redirectparams', wfArrayToCgi( 
$params ) );
+               }
 
                // Give hooks a chance to alter the form, adding extra fields 
or text etc
                Hooks::run( 'SpecialPageBeforeFormDisplay', [ $this->getName(), 
&$form ] );

-- 
To view, visit https://gerrit.wikimedia.org/r/316705
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9bc930e5dca557571b4658444fea6aec59c5797a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to