Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.2.16

Bug #19760 Notice array to string conversion in required rule in PHP 5.4
Submitted: 2012-12-25 17:57 UTC
From: joris Assigned: ashnazg
Status: Closed Package: HTML_QuickForm (version 3.2.13)
PHP Version: 5.4.8 OS: Debian / doesn't matter
Roadmaps: (Not assigned)    
Subscription  


 [2012-12-25 17:57 UTC] joris (Joris van de Sande)
Description: ------------ Line 50 "if ((string)$value == '') {" in HTML_QuickForm_Rule_Required emits the following PHP notice in PHP 5.4 when an array value is given: Notice: Array to string conversion in /path/to/pear/HTML/QuickForm/Rule/Required.php on line 50 This notice is introduced in PHP 5.4 (http://php.net/manual/en/migration54.incompatible.php). Attached is a possible solution. Test script: --------------- $form = new HTML_QuickForm(); $elem = $form->addElement('select', 'elem', array(1 => 'One', 2 => 'Two')); $elem->setMultiple(true); $form->addRule('elem', 'This field is required', 'required'); $form->validate(); Expected result: ---------------- Validation passes without notices when an array is posted. Actual result: -------------- The validation still passes, but a notice is shown: Notice: Array to string conversion in /path/to/pear/HTML/QuickForm/Rule/Required.php on line 50

Comments

 [2012-12-25 18:01 UTC] joris (Joris van de Sande)
 [2013-11-15 02:06 UTC] fhadf234 (Noel Lastname)
This should be fixed and the pear package updated since bugs are supposed to get maintained.
 [2018-07-19 20:24 UTC] ashnazg (Chuck Burgess)
-Status: Open +Status: Closed -Assigned To: +Assigned To: ashnazg
This was fixed in v3.2.14.