#49241 [Opn->Bgs]: error in code by array just after upgrade 5.3

From: Date: Wed, 12 Aug 2009 22:54:40 +0000
Subject: #49241 [Opn->Bgs]: error in code by array just after upgrade 5.3
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-140994@lists.php.net to get a copy of this message
 ID:               49241
 Updated by:       scottmac@php.net
 Reported By:      yakucorp at gmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         PHP options/info functions
 Operating System: centos 5.3
 PHP Version:      5.3.0
 New Comment:

The manual says about call_user_func_array():
"Note: Referenced variables in param_arr  are passed to the function
by
a reference, others are passed by a value. In other words, it does not
depend on the function signature whether the parameter is passed by a
value or by a reference. "


array_multisort expects an array by reference, but when you use
call_user_func_array in your code its not a reference just a regular
variable.

This worked by accident in PHP 5.2.




Previous Comments:
------------------------------------------------------------------------

[2009-08-12 22:25:43] yakucorp at gmail dot com

Description:
------------
I just upgrade my php v to 5.3 and it appears this error.
this is my old script, and returns error like this




Reproduce code:
---------------
function fn_array_multisort()
{
	$n = func_num_args();
	$ar = func_get_arg(0);
	if(!is_array($ar)){
		return false;
	}

	for($i = 1; $i < $n; $i++){
		$col[$i] = func_get_arg($i);
	}

	foreach($ar as $key => $val){
		foreach($col as $kkey => $vval){
			if(is_string($vval)){
				${"subar$kkey"}[$key] = isset($val[$vval]) ? $val[$vval] : '';
			}
		}
	}

	$arv = array();
	foreach($col as $key => $val){
		$arv[] = (is_string($val) ? ${"subar$key"} : $val);
	}
	$arv[] = $ar;
	call_user_func_array("array_multisort", $arv);

	return $ar;
}

Expected result:
----------------
Warning: Parameter 1 to array_multisort() expected to be a reference,
value given in /usr/local/nginx/html/fox/core/fn_common.php on line
2000

Warning: Parameter 1 to array_multisort() expected to be a reference,
value given in /usr/local/nginx/html/fox/core/fn_common.php on line
2000

Warning: Parameter 1 to array_multisort() expected to be a reference,
value given in /usr/local/nginx/html/fox/core/fn_common.php on line
2000

Warning: Parameter 1 to array_multisort() expected to be a reference,
value given in /usr/local/nginx/html/fox/core/fn_common.php on line
2000

Warning: Parameter 1 to array_multisort() expected to be a reference,
value given in /usr/local/nginx/html/fox/core/fn_common.php on line 2000

Actual result:
--------------
call_user_func_array("array_multisort", $arv);

this line might be the clue call_user_func_array("array_multisort",
$arv);
please help, thanks


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=49241&edit=1



Thread (4 messages)

« previous php.bugs (#140994) next »