Bug #67100 [NEW]: Array copy and reference problem in pecl module.
| From: | greevex at gmail dot com | Date: | Mon, 21 Apr 2014 08:26:27 +0000 |
| Subject: | Bug #67100 [NEW]: Array copy and reference problem in pecl module. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-185353@lists.php.net to get a copy of this message | ||
From: greevex at gmail dot com
Operating system: Scientific Linux 6.5
PHP version: 5.5.11
Package: Scripting Engine problem
Bug Type: Bug
Bug description:Array copy and reference problem in pecl module.
Description:
------------
php-pecl-mongo version 1.4.5
I don't really think that it's problem in mongo pecl module, because
this is problem of an inside PHP Engine (optimizations for passing
variables by reference before it's changed).
Test script:
---------------
function prepare() {
return [
'key' => 'test1',
'create' => time(),
'update' => 0,
'value' => 0
];
}
function save($array2) {
$db = (new Mongo('localhost'))->selectDB('test');
$collection = $db->selectCollection('test');
// array2: new field
_id would be added, insert requesting param
by reference
$collection->insert($array2);
// some field only in array1, but _id field in both arrays
return $array2;
}
$array1 = prepare();
$array2 = save($array1);
// array1: add some field to array1
$array1['some'] = true;
var_dump(isset($array1['_id']), isset($array2['_id']),
isset($array1['some']), isset($array2['some']));
Expected result:
----------------
bool(false)
bool(true)
bool(true)
bool(false)
Actual result:
--------------
bool(true)
bool(true)
bool(true)
bool(false)
--
Edit bug report at https://bugs.php.net/bug.php?id=67100&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=67100&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=67100&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=67100&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=67100&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=67100&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=67100&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=67100&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=67100&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=67100&r=support
Expected behavior: https://bugs.php.net/fix.php?id=67100&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=67100&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=67100&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=67100&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=67100&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=67100&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=67100&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=67100&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=67100&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=67100&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=67100&r=mysqlcfg