[PHP-BUG] Bug #74297 [NEW]: Simple comparison fails
[email protected] ("arjen at parse dot nl")
| Newsgroups | php.bugs |
|---|---|
| Message-ID | <[email protected]> |
From: arjen at parse dot nl
Operating system: Linux
PHP version: 7.1.3
Package: opcache
Bug Type: Bug
Bug description:Simple comparison fails
Description:
------------
php-memcached 3.0.3
libmemcached 1.0.18
memcached 1.4.32
php 7.1.3
Both memcached and opcache needs to be loaded. opcache.enable_cli is not
needed.
php -n -dextension=memcached.so -dzend_extension=opcache.so script.php
If the value ('test') set in memcached is changed, the script no longer
fails.
($e == $a) === false, while ($a == $e) === true...
Test script:
---------------
<?php
class r
{
public $d = ['test' => 'x'];
public function m()
{
return [] + $this->d;
}
}
(function()
{
$m = new memcached;
$m->addServer('127.0.0.1', 11211);
$m->set('Something', 'test');
$e = ['test' => 'x'];
$a = (new r)->m();
if (0 == ($e <=> $a))
return 'success';
var_dump([$e, $a]);
var_dump([serialize($e), serialize($a)]);
var_dump([
'e === a' => $e === $a,
'e == a' => $e == $a,
'e <=> a' => $e <=> $a,
'a <=> e' => $a <=> $e,
'a === e' => $a === $e,
'a == e' => $a == $e]
);
var_dump(debug_zval_dump($e), debug_zval_dump($a));
die('this should not happen');
})();
Expected result:
----------------
success
Actual result:
--------------
array(2) {
[0]=>
array(1) {
["test"]=>
string(1) "x"
}
[1]=>
array(1) {
["test"]=>
string(1) "x"
}
}
array(2) {
[0]=>
string(25) "a:1:{s:4:"test";s:1:"x";}"
[1]=>
string(25) "a:1:{s:4:"test";s:1:"x";}"
}
array(6) {
["e === a"]=>
bool(true)
["e == a"]=>
bool(false)
["e <=> a"]=>
int(1)
["a <=> e"]=>
int(0)
["a === e"]=>
bool(true)
["a == e"]=>
bool(true)
}
array(1) refcount(1){
["test"]=>
string(1) "x" refcount(1)
}
array(1) refcount(2){
["test"]=>
string(1) "x" refcount(1)
}
--
Edit bug report at https://bugs.php.net/bug.php?id=74297&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74297&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74297&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74297&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74297&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74297&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74297&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74297&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74297&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74297&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74297&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74297&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74297&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74297&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74297&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74297&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74297&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74297&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74297&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74297&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74297&r=mysqlcfg