Florianschmidtwelzow has uploaded a new change for review.


Change subject: Fix HTMLMultiSelectField when used with GET forms

Fix HTMLMultiSelectField when used with GET forms

HTMLForm is (since some versions ago) better in recognizing, if a
form was submitted, even if GET is used. However, it's still not
perfect, therefore: relying on HTMLFormField::isSubmitAttempt() for
things that need to work, even if GET is used, isn't always safe.

HTMLMultSelectField uses this method to recognize, if values are
submitted, which doesn't work at all for GET forms, which doesn't use
form identifiers. With this commit, when the values for the field
are loaded, it will check, if the field is present in the request,
if the form isn't recognized as submitted.

Bug: T147705
Change-Id: I1a5129eb6d24c3f4963bf63e9db9a41f68ef3bbc
M includes/htmlform/fields/HTMLMultiSelectField.php
1 file changed, 1 insertion(+), 1 deletion(-)

  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 

diff --git a/includes/htmlform/fields/HTMLMultiSelectField.php 
index c9fcb09..5985ddf 100644
--- a/includes/htmlform/fields/HTMLMultiSelectField.php
+++ b/includes/htmlform/fields/HTMLMultiSelectField.php
@@ -150,7 +150,7 @@
         * @return string
        function loadDataFromRequest( $request ) {
-               if ( $this->isSubmitAttempt( $request ) ) {
+               if ( $this->isSubmitAttempt( $request ) || $request->getArray( 
$this->mName ) !== null ) {
                        // Checkboxes are just not added to the request arrays 
if they're not checked,
                        // so it's perfectly possible for there not to be an 
entry at all
                        return $request->getArray( $this->mName, [] );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1a5129eb6d24c3f4963bf63e9db9a41f68ef3bbc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <florian.schmidt.stargatewis...@gmail.com>

MediaWiki-commits mailing list

Reply via email to