Mantis - Quercus
Viewing Issue Advanced Details
607 minor always 12-01-05 05:59 01-03-06 20:46
bago  
 
normal  
closed  
fixed  
none    
none 3.0.18  
0000607: func_get_args should copy the values and not use references!
http://www.php.net/func_get_args [^]
"Note: This function returns a copy of the passed arguments only, and does not account for default (non-passed) arguments."
<?php
function mixedargs() {
  $args = func_get_args();
  $args[0]['a'] = "byreference";
}

$test = array('a'=>"byvalue");
mixedargs($test);
print($test['a']);
?>

in original php this output "byvalue", in quercus this output "byreference".

Here is a patch (I still don't know very well the quercus codebase, maybe this is not correct, but it fixed my problem).

Index: modules/quercus/src/com/caucho/quercus/lib/QuercusFunctionModule.java
===================================================================
--- modules/quercus/src/com/caucho/quercus/lib/QuercusFunctionModule.java (revision 493)
+++ modules/quercus/src/com/caucho/quercus/lib/QuercusFunctionModule.java (working copy)
@@ -120,7 +120,7 @@
     Value []args = env.getFunctionArgs();
 
     if (0 <= index && index < args.length)
- return args[index];
+ return args[index].copy();
     else {
       // XXX: warning
       return NullValue.NULL;
@@ -137,7 +137,7 @@
 
     ArrayValue result = new ArrayValueImpl();
     for (int i = 0; i < args.length; i++)
- result.append(args[i]);
+ result.append(args[i].copy());
 
     return result;
   }

Notes
(0000622)
bago   
12-01-05 06:40   
Well, the current trunk after this fix seems to run drupal! :-)
I just tried a few functions but I didn't encounter big problems.
(0000634)
ferg   
01-03-06 20:46   
php/0479, 047a, 3479, 347a