Sviluppa php, Marco Pilolli programmatore php

Information

This article was written on 04 Gen 2012, and is filled under Blog, Phpinfo.

Current post is tagged

, , , ,

Parameter 3 to showItem()

Passando da un server all’altro una vecchia installazione di joomla 1.0 (passare a joomla 1.5 sarebbe troppo oneroso) con php versione 5.3.2 da il seguente errore:
Warning: Parameter 3 to showItem() expected to be a reference, value given in /home/myhomedir/public_html/includes/Cache/Lite/Function.php on line 100
la soluzione l’ho trovata qui http://php.net/manual/en/function.call-user-func-array.php

mettendo questa funzione :
function &ref_call_user_func_array($callable, $args)
{
if(is_scalar($callable))
{
// $callable is the name of a function
$call = $callable;
}
else
{
if(is_object($callable[0]))
{
// $callable is an object and a method name
$call = “\$callable[0]->{$callable[1]}”;
}
else
{
// $callable is a class name and a static method
$call = “{$callable[0]}::{$callable[1]}”;
}
}
// Note because the keys in $args might be strings
// we do this in a slightly round about way.
$argumentString = array();
$argumentKeys = array_keys($args);
foreach($argumentKeys as $argK)
{
$argumentString[] = “\$args[$argumentKeys[$argK]]”;
}
$argumentString = implode($argumentString, ‘, ‘);
// Note also that eval doesn’t return references, so we
// work around it in this way…
eval(“\$result =& {$call}({$argumentString});”);
return $result;
}

nel file includes/Cache/Lite/Function.php
modificando le linee 92 e 100
modificandole da
$result = call_user_func_array(array($class, $method), $arguments);
a
$result = ref_call_user_func_array(array($class, $method), $arguments);

e da
$result = call_user_func_array($target, $arguments);
a
$result = ref_call_user_func_array($target, $arguments);

Lascia un commento