Because php tends to copy objects every time they are assigned to a variable or passed by or to a function, phpPeanuts extensively uses variable references. We occasionally ran into a variable or array that suddenly held a value that was clearly not put there by our code. It was previously assigned to a totally different variable. Once it even came out of an array whenever we asked for a key that was not present. In other occasions the variable was uninitialized.
In version 1.0a a workaround was introduced: When returning a reference to a field value of a primitive type returned by value by a method call, assigning the valeu to a temporary variable and returning a referency to that variable seemed to solve the problem.
Because the reproduction of these anomalies requires all the code that was run, including the framework, as well as the data, we did not yet come across a situation feasable to be properly documented in a bug report, so we never reported it to php.net. However, php 4.4.0 release announcement problems are descibed that may be Reference Anomalies or may be related to them. Php 4.4.0 is meant to solve those problems, so maybe php 4.4.0 will help to get rid of the kind of reference anomalies we found.
Remarkebly enough a new reference anomaly was found when the changes where made to get rid of reference notifications triggered by php5.2. The anomaly disappeared after the conversion of references to values and vice versa where avoided whenever possible.
We expect that these problems will anyway disappear in php 5 when we can use object references instead of variable references. In the mean time (at least as long as phpPeanuts is kept portable between php4 and php5) we keep our workaround in place. Since version 1.3.beta3 we try to: avoid reference nofitications, avoid returning references to variables that doe not exesit and try to avoid converting values to references and vice versa.
Read How to avoid Reference Anomalies.
PS. Returning a reference to an uninitialized variable is quite an effective way make the current script crash without notice. The fields causing anomalies had been initialized. |