From: rodji at tut dot by
Operating system: Win32 XP sp2.2600
PHP version: 4.4.7
PHP Bug Type: Scripting Engine problem
Bug description: extract EXTR_REFS and/or references
Description:
------------
Tested on:
Apache/1.3.33 (Win32)
PHP/4.4.7 and 5.2.3
trouble with references in functions
Reproduce code:
---------------
function args_select($args, $args_list, $def_val) {
$r = array();
foreach ($args_list as $key) {
if (array_key_exists($key, $args)){
$r[$key] = $args[$key];
}else{
$r[$key] = $def_val; //equal $r[$key] =& $def_val
why???
//$r[$key] = (string)$def_val; //solution#1
}
}
return $r;
}
$argums = array('action'=>'edit', 'id'=>1);
$select = array('action','to_do','back');
//debug_zval_dump(args_select($argums, $select, ''));
extract(args_select($argums, $select, ''), EXTR_OVERWRITE | EXTR_REFS);
//solution#2 why???
/*$m = args_select($argums, $select, '');
//OR //$m =& args_select($argums, $select, '');
extract($m, EXTR_OVERWRITE | EXTR_REFS);
*/
$to_do = 'new';
debug_zval_dump (&$back);
?>
Expected result:
----------------
&string(0) "" refcount(2)
Actual result:
--------------
&string(3) "new" refcount(3)
--
Edit bug report at http://bugs.php.net/?id=42271&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=42271&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=42271&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=42271&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=42271&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=42271&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=42271&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=42271&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=42271&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=42271&r=support
Expected behavior: http://bugs.php.net/fix.php?id=42271&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=42271&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=42271&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=42271&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42271&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=42271&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=42271&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=42271&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=42271&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=42271&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=42271&r=mysqlcfg