checkbox could not be checked through URL parameter
authorAntoine Musso <hashar@users.mediawiki.org>
Tue, 1 Nov 2011 09:28:51 +0000 (09:28 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Tue, 1 Nov 2011 09:28:51 +0000 (09:28 +0000)
On [[Special:EmailUser]], someone ought to be able to pass the checkboxes
names to overrides the default. As an example from bug 31770, the email
user page has a checkbox wpCCMe which let the user as for a copy of the
email being send. This is a user preference.

One change that checkbox state by appending ?wpCCMe=<boolean> ie:
Special:EmailUser/Hashar?wpCCMe=0
Special:EmailUser/Hashar?wpCCMe=1

The logic added in r84814 could have allowed checkboxes to be overriden
for GET form. Unfortunately, HTMLForm is mostly with the default POST.
Hence, when appending the query parameter, we would never honor it!

The fix is to still unconditionally look at the value if the form was
correctly submitted (ie has wpEditToken) and additionaly whenever
there is a checkbox name appearing in the query (wherever it is false
or true, hence the use of getVal()).

This is a regression in REL1_18.  I dont think it deserves a release notes
since it is not fixing anything compared to 1.17.

Bug fixed:
==========
* (bug 31770) Allow URL parameter wpCCMe on Special:EmailUser
* (bug 30909) URL parameters for checkboxes in Special:Block no longer work

includes/HTMLForm.php

index f883967..b781534 100644 (file)
@@ -1376,7 +1376,10 @@ class HTMLCheckField extends HTMLFormField {
                }
 
                // GetCheck won't work like we want for checks.
-               if ( $request->getCheck( 'wpEditToken' ) || $this->mParent->getMethod() != 'post' ) {
+               // Fetch the value in either one of the two following case:
+               // - we have a valid token (form got posted or GET forged by the user)
+               // - checkbox name has a value (false or true), ie is not null
+               if ( $request->getCheck( 'wpEditToken' ) || $request->getVal( $this->mName )!== null ) {
                        // XOR has the following truth table, which is what we want
                        // INVERT VALUE | OUTPUT
                        // true   true  | false