Mantis - Quercus
Viewing Issue Advanced Details
2539 minor always 03-19-08 21:27 03-21-08 13:19
ckchris  
nam  
normal  
closed  
fixed  
none    
none 3.1.6  
0002539: a zero value Double or Float Value type should return "0" when converted to String
I ran into a problem with an unexpected behavior when running phpBB3.

There is a code inside phpBB3's includes/db/mysqli.php that does a float-based division. A floor() is then applied to it. The return value of a floor() is a float value, which is expected and is the proper behavior that Quercus exhibits.

However, the problem is that the floor'ed value is appended to a SQL query string for the "limit x, y" part of the query. Unfortunately, the toString() for the float value of 0 returned "0.0" when run under quercus. This turned the limit string into "limit 0.0, 10", which mysql driver throws an exception.

I recommend that the Double and Float and Decimal value types should check for 0, and if so, return "0" for the string instead of "0.0" to retain compatible behavior with PHP.

Notes
(0002871)
nam   
03-20-08 19:36   
What Quercus version are you using? I remember this issue being fixed for 3.1.4 or 3.1.5. You might want to give 3.1.5 a try.
(0002873)
ckchris   
03-20-08 20:05   
Running the latest quercus version compiled straight off the SVN that's checked out as of today. Revision 3969.

I did a double confirmation and removed the (int) type conversion in mysqli.php in phpbb3. The line is originally this:

 $query .= "\n LIMIT " . ((!empty($offset)) ? $offset . ', ' . $total : $total);

Running it with the newest SVN snapshot still gives me the error. By adding this a forced type conversion:

 $query .= "\n LIMIT " . ((!empty($offset)) ? (int) $offset . ', ' . $total : $total);

Things worked after that. Previously, I was using 3.1.5. And before that I was using the version that came with Resin 3.1.5.

(0002875)
nam   
03-21-08 13:19   
php/033k

issue only seen if the float is on the left hand side of an append ('.')
i.e. var_dump(10.0 . ", 10")