Bug #62097 [Asn]: New behavior of string == has a compatibility problem
| From: | stas@php.net | Date: | Thu, 31 May 2012 00:46:41 +0000 |
| Subject: | Bug #62097 [Asn]: New behavior of string == has a compatibility problem | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-170940@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=62097&edit=1
ID: 62097
Updated by: stas@php.net
Reported by: kazuo at o-ishi dot jp
Summary: New behavior of string == has a compatibility
problem
Status: Assigned
Type: Bug
Package: Scripting Engine problem
Operating System: Gentoo Linux
PHP Version: 5.4.4RC1
Assigned To: stas
Block user comment: N
Private report: N
New Comment:
I do not see "heavy" impact - so far I did not see any code sample that did
something that makes sense in 5.4.3 but not on 5.4.4. If you have such code
sample and can explain what data it accepts, what it does and why it relies on
string comparisons cutting numbers, please do so. Your database example is
missing data, so I can not see what is going on there and why you think it works
differently in 5.4.3 and 5.4.4.
Previous Comments:
------------------------------------------------------------------------
[2012-05-30 08:57:43] kazuo at o-ishi dot jp
In summary, this is my opinion:
Recent changes on string == have problems on compatibility.
Impact of the behavior change of == operator is heavy.
This change should be excluded from PHP 5.4.x series.
I'm sure that current (old) behavior also have problems, but
compatibility is better.
If it will be changed, it should be a natural extension of current
behavior; number-like string is compared as number.
(e.g. canonicalize string as number way before memcmp.)
Of course, such behavior should be described explicitly in PHP Manual.
------------------------------------------------------------------------
[2012-05-30 07:18:45] kazuo at o-ishi dot jp
Please think that it is money (or member ID).
But why?
------------------------------------------------------------------------
[2012-05-30 07:09:15] stas@php.net
What is in $row[0] in your example?
------------------------------------------------------------------------
[2012-05-30 06:17:28] stas@php.net
Automatic comment on behalf of cataphract
Revision: http://git.php.net/?p=php-src.git;a=commit;h=78ff9ebb6bb501dff995727512c38fdeff50021b
Log: Fixed bug #62097
------------------------------------------------------------------------
[2012-05-29 09:04:37] kazuo at o-ishi dot jp
Interface to user inputs or external format may rely on current
(released version of ) PHP behavior, ignore leading zeros or whitespaces.
I'm sorry that I cannot show you simple example.
Instead, this is example to show another incompatibility:
There is pgsql database table created by
CREATE TABLE t (k INT, v NUMERIC(30,1));
This code print "true" on PHP 5.4.3 but "false" on latest.
-------------------------------------------------
<?php
$key = "1";
$num = "12345678901234567890";
$con = pg_connect("...");
pg_query($con, "DELETE FROM t");
pg_query($con, "INSERT INTO t (k, v) VALUES ($key, $num)");
$rs = pg_query($con, "SELECT v FROM t WHERE k = $key");
$row = pg_fetch_row($rs);
if ($row[0] == $num) {
echo "true";
} else {
echo "false";
}
-------------------------------------------------
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=62097
--
Edit this bug report at https://bugs.php.net/bug.php?id=62097&edit=1