From 1debab271ecdbedf7a88bfd707825a6e8b6a8543 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Tue, 1 Nov 2011 09:28:51 +0000 Subject: [PATCH] checkbox could not be checked through URL parameter 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= 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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index f883967159..b781534549 100644 --- a/includes/HTMLForm.php +++ b/includes/HTMLForm.php @@ -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 -- 2.20.1