Re: RC4

From: Date: Fri, 08 Dec 2000 18:48:30 +0000
Subject: Re: RC4
References: 1  Groups: php.qa 
Request: Send a blank email to php-qa+get-1764@lists.php.net to get a copy of this message
At 20:20 8/12/2000, André Langhorst wrote:
    Are you referring to that PHP code which scans through the
    serialized representation of a couple of objects and uses
    that to create and eval'uate the class definitions?
yes
b) bug 7515
    That script assumes that arrays and all members thereof are
    copied when passed to a function. That is not the case.
could you elaborate? do you want to tell me that arrays and objects will be garbled passing them to a function??? and what would that have to do with the strange behaviour introduced by simply calling a method? did you simply comment the mentioned line out and watched the results?
It's rather simple. The two container types in PHP (arrays and objects), may contain references in them. When you pass these containers by value, any references they may contain remain referenced, and are not separated. This means that the two copies, the original and the new one, will contain elements which are referenced to each other. That's wha Andi said when he meant that the engine currently does 'shallow copy', and not a 'deep copy' - when copying a value, we don't search inside it, to see if it may contain references that have to be separated. We just increase the reference count. Fixing this behavior, which admittedly can be quite annoying (although it's much easier to work with it once you're aware of how it works) is fairly complex, and the current solution that we have in mind is extremely inefficient in the general case. This issue will definitely not be solved for 4.0.4. Zeev -- Zeev Suraski <zeev@zend.com> CTO, Zend Technologies Ltd. http://www.zend.com/

« previous php.qa (#1764) next »