Mantis - Quercus
Viewing Issue Advanced Details
3372 block always 03-05-09 18:54 03-06-09 13:39
koreth  
nam  
normal  
closed 4.0.0  
fixed  
none    
none 4.0.0  
0003372: Refs not preserved
<?php

function setup(&$pending=null) {
  $GLOBALS['LIST'][] = array(
    'ref' => &$pending,
  );
}

function dispatch() {
  foreach ($GLOBALS['LIST'] as $entry) {
    $ref = &$entry['ref'];
    $ref = 'xyzzy';
  }
}

$x = null;
setup($x);
dispatch();
print strlen($x);

Regular PHP prints "5". Quercus prints "0" -- somewhere along the line it loses the fact that it's dealing with a reference, and no value gets assigned to $x.

Notes
(0003865)
koreth   
03-05-09 22:43   
This change to ArrayValueImpl.getRef(Value) seems to fix the test case, but it is most likely not the right fix (I imagine the Var-rewrapping logic was there for a reason.)

--- a/modules/quercus/src/com/caucho/quercus/env/ArrayValueImpl.java
+++ b/modules/quercus/src/com/caucho/quercus/env/ArrayValueImpl.java
@@ -944,7 +944,7 @@ public class ArrayValueImpl extends ArrayValue
       return var;
     
     if (entry._value instanceof Var)
- var = new Var(entry._value.toValue());
+ var = (Var) entry._value;
     else
       var = new Var(entry._value);
(0003868)
nam   
03-06-09 13:39   
php/066y