Posted by EllRod on January 19, 2012 at 2:05pm
Har en Site med Drupal 6 installerad, den har blivit lite övergiven. Och nu har jag märkt att jag kan inte längre ladda upp "Slide images" som tidigare. Eftersom jag byggde inte den ursprungligen så hänger jag inte med vad som kan ha gått fel, på tanke att jag knapp jobbat med sajten.
Felmeddelande som jag får upp är följande:
warning: Parameter 1 to imageapi_gd_image_resize() expected to be a reference, value given in D:\apache\htdocs-creativelight.com\sites\all\modules\contribs\imageapi\imageapi.module on line 165.
kollat in raden enligt felmeddelandet:
/**
* Invokes the given method using the currently selected toolkit.
*
* @param $method
* A string containing the method to invoke.
* @param $image
* An image object returned by imageapi_image_open().
* @param $params
* An optional array of parameters to pass to the toolkit method.
* @return
* Mixed values (typically Boolean indicating successful operation).
*/
function imageapi_toolkit_invoke($method, &$image, array $params = array()) {
$function = $image->toolkit . '_image_' . $method;
if (function_exists($function)) {
array_unshift($params, $image);
Line165: return call_user_func_array($function, $params);
}
watchdog('imageapi', 'The selected image handling toolkit %toolkit can not correctly process %function.', array('%toolkit' => $image->toolkit, '%function' => $function), WATCHDOG_ERROR);
return FALSE;
}verka bli något form av miss, när funktionen efterfrågar en parameter.
Någon som känner igen problemet???

Comments
Troligen beror det på att du
Troligen beror det på att du kör PHP 5.3. Se denna issue.
//Pontus Nilsson, Digitalist
The problem is that in php
The problem is that in php 5.3 parameters need to be called by reference or call_user_func_array will quit. This is not the case with php 5.2 where it would just load the function anyway. The patches in the thread are not optimal since they use an array construct which could make things weird if the same solution is used elsewhere in Drupal. Since Drupal uses foreach() on objects and arrays a better solution is to assigned the reference directly to the loop element.
<?php
foreach($params as &$param) {
$param = $param;
}
if (function_exists($function)) {
array_unshift($params, $image);
return call_user_func_array($function, $params);
?>
This should make each parameter a reference to each orginal.
Notice: I have not tested this in any way!!!
Carl McDade
Drupal Source Exchange - alpha
Okay, I checked this out more
Okay, I checked this out more closely and I find it very irritating. Neither PHP or Drupal have any conventions on this which results in refactoring by PHP version. In PHP 5.3:
But in previous versions using the ampersand is okay:
<?php
error_reporting(E_ALL);
function increment(&$var)
{
$var++;
}
$a = 0;
call_user_func('increment', $a);
echo $a."\n";
call_user_func_array('increment', array(&$a)); // You can use this instead before PHP 5.3
echo $a."\n";
?>
And of course if Drupal used proper OO this problem might not exist :(
Carl McDade
Drupal Source Exchange - alpha