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

Bug #10754 Validation of large numbers broken in HTML_QuickForm_Rule_Compare
Submitted: 2007-04-17 09:33 UTC Modified: 2007-06-03 13:56 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-17 09:33 UTC] patrik (Patrik Lermon)
Description: ------------ If this rule is created: $form->addRule(array('FromAccount', 'ToAccount'), 'You cannot transfer money to and from same account', 'compare', 'neq', 'client'); FromAccount contains "0008000231ngs0000114151" ToAccount contains "00080002310000114152" The comparision made in HTML_QuickForm_Rule_Compare will do basically this (line 77): return "00080002310000114151" != "00080002310000114152"; This will return false because PHP interprets the strings as numbers. One solution for this would be to use !== and === operators instead. Test script: --------------- // First the not equal test echo ("00080002310000114151" != "00080002310000114152" ? "TRUE" : "FALSE")."\n"; // outputs FALSE echo ("00080002310000114151" !== "00080002310000114152" ? "TRUE" : "FALSE")."\n"; // outputs TRUE (correct) // Then also the equality test php5 -r 'echo ("00080002310000114151" == "00080002310000114152" ? "TRUE" : "FALSE")."\n"; // outputs TRUE php5 -r 'echo ("00080002310000114151" === "00080002310000114152" ? "TRUE" : "FALSE")."\n"; // outputs FALSE (correct) Expected result: ---------------- The comparision works both on server and client side.

Comments

 [2007-04-17 09:44 UTC] patrik (Patrik Lermon)
Typo
 [2007-04-24 17:31 UTC] patrik (Patrik Lermon)
Yet another typo (awfully sorry). In the description it sez: FromAccount contains "0008000231ngs0000114151" That should be: FromAccount contains "00080002310000114151" (the "ngs" should be taken away)
 [2007-04-25 07:51 UTC] patrik (Patrik Lermon)
Problems alike are described in #10837
 [2007-05-29 14:28 UTC] avb (Alexey Borzov)
Yeah, the problem is indeed there.
 [2007-06-03 13:56 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.