Bug #63071 [NEW]: func_get_args loses byref information

From: Date: Wed, 12 Sep 2012 11:00:08 +0000
Subject: Bug #63071 [NEW]: func_get_args loses byref information
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-173367@lists.php.net to get a copy of this message
From:             maarten at ba dot be
Operating system: all
PHP version:      5.3.16
Package:          Unknown/Other Function
Bug Type:         Bug
Bug description:func_get_args loses byref information

Description:
------------
i'm writing code that invokes "hooks" with byref parameters.

but the generalized hook functions lose the byref information due to
func_get_args being a copy (but not exact), thus call_user_func_array()
(which needs to have references in it's array) can't work.

see shortened example below:

Test script:
---------------
$foo = "foo";
$bar = "bar";
function func_a(&$a, $b) {
  $a = $b;
};
function c() {
  $args = func_get_args();
  call_user_func_array("func_a", $args);
};
c(&$foo, $bar);
var_dump($foo);

Expected result:
----------------
i expected for $foo to have 'bar'

Actual result:
--------------
$foo is still 'foo', and a warning is generated

-- 
Edit bug report at https://bugs.php.net/bug.php?id=63071&edit=1
-- 
Try a snapshot (PHP 5.4):            https://bugs.php.net/fix.php?id=63071&r=trysnapshot54
Try a snapshot (PHP 5.3):            https://bugs.php.net/fix.php?id=63071&r=trysnapshot53
Try a snapshot (trunk):              https://bugs.php.net/fix.php?id=63071&r=trysnapshottrunk
Fixed in SVN:                        https://bugs.php.net/fix.php?id=63071&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=63071&r=needdocs
Fixed in release:                    https://bugs.php.net/fix.php?id=63071&r=alreadyfixed
Need backtrace:                      https://bugs.php.net/fix.php?id=63071&r=needtrace
Need Reproduce Script:               https://bugs.php.net/fix.php?id=63071&r=needscript
Try newer version:                   https://bugs.php.net/fix.php?id=63071&r=oldversion
Not developer issue:                 https://bugs.php.net/fix.php?id=63071&r=support
Expected behavior:                   https://bugs.php.net/fix.php?id=63071&r=notwrong
Not enough info:                     https://bugs.php.net/fix.php?id=63071&r=notenoughinfo
Submitted twice:                     https://bugs.php.net/fix.php?id=63071&r=submittedtwice
register_globals:                    https://bugs.php.net/fix.php?id=63071&r=globals
PHP 4 support discontinued:          https://bugs.php.net/fix.php?id=63071&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=63071&r=dst
IIS Stability:                       https://bugs.php.net/fix.php?id=63071&r=isapi
Install GNU Sed:                     https://bugs.php.net/fix.php?id=63071&r=gnused
Floating point limitations:          https://bugs.php.net/fix.php?id=63071&r=float
No Zend Extensions:                  https://bugs.php.net/fix.php?id=63071&r=nozend
MySQL Configuration Error:           https://bugs.php.net/fix.php?id=63071&r=mysqlcfg



Thread (4 messages)

« previous php.bugs (#173367) next »