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

Bug #10837 Large numbers in selects breakes
Submitted: 2007-04-25 12:50 UTC
From: patrik Assigned: avb
Status: Closed Package: HTML_QuickForm (version 3.2.7)
PHP Version: 5.1.6 OS: Ubuntu 6.10
Roadmaps: 3.2.8    
Subscription  


 [2007-04-25 12:50 UTC] patrik (Patrik Lermon)
Description: ------------ If a large number is used in a quickform select, the internal code will use the operators which tries to compare the strings as numbers, and if the evaluated number is bigger than PHP can handle this will result in unexpected results. The problem is the == operator, which compares strings as numbers, if the string all consists of numbers. This means you can not have a drop down consisting of only large numbers (like account numbers) or you will have problems. The solution is to use the === operator for comparison instead. You also have to be careful when using functions like in_array() which seems to use the == operator internal. In cases like this you must write your own array searching algorithms. It seems that it is NOT sufficient to cast the variables to strings (they are already strings), the problem is the == operator itself. Test script: --------------- include('HTML/QuickForm.php'); include('HTML/QuickForm/select.php'); $form = new HTML_QuickForm('bignum'); $select_fromaccount = new HTML_QuickForm_select("FromAccount", "From account", array('00080002310000114151'=>'00080002310000114151', '00080002310000114152'=>'00080002310000114152')); $select_toaccount = new HTML_QuickForm_select("ToAccount", "To account", array('00080002310000114151'=>'00080002310000114151', '00080002310000114152'=>'00080002310000114152')); $form->addElement($select_fromaccount); $form->addElement($select_toaccount); $form->addElement('submit', null, 'Send'); $form->display(); Expected result: ---------------- If you open the script above, choose different from- and to-account and press submit, the resulting page will have all options marked as selected (check the resulting source code). This is due to an in_array() comparison in HTML/QuickForm/select.php. If you apply the patch in HTML/QuickForm/select.php and do the same procedure, you will see only one option selected. I assume that for form elements besided select is having similar problems.

Comments

 [2007-04-25 12:51 UTC] patrik (Patrik Lermon)
The bug is similar to #10754
 [2007-06-03 15:01 UTC] avb (Alexey Borzov)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.