|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-02-28 17:21 UTC] cmb@php.net
-Package: Scripting Engine problem
+Package: mongo
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 16:00:01 2025 UTC |
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)