0

Message error: 3 passed and at least 4 expected. I understand that 7.1 creates a fatal error but I don't understand why it is expecting 4 arguments in this case and it says that it passed 3 arguments instead of the two normally accepted with call_user_func_array. The error is indicated on this line:

$ret = call_user_func_array(array($this->loadedPlugins[$this->availableMethods[$method]], $method), $args);

After reading the php documentation about user_func_array I saw that the array should be in the second position, so I tried to inverse them :

call_user_func_array($args, array($this->loadedPlugins[$this->availableMethods[$method]], $method));

In this case the error disappears but the images are not showing. This use to work in php5.6 and php7. Any help is appreciated

public function execute($cmd){

    $ret = null ;
    $out = array();

    if($this->escapeChars) {
        $cmd= str_replace    ('(','\(',$cmd);
        $cmd= str_replace    (')','\)',$cmd);
    }
    exec( $cmd .' 2>&1', $out, $ret);

    if($ret != 0)
        if($this->debug) trigger_error (new phMagickException ('Error executing "'. $cmd.'" <br>return code: '. $ret .' <br>command output :"'. implode("<br>", $out).'"' ), E_USER_NOTICE );

    $this->log[] = array(
        'cmd' => $cmd
        ,'return' => $ret
        ,'output' => $out
    );

    return $ret ;
}

public function __call($method, $args){
    if(! key_exists($method, $this->availableMethods))
       throw new Exception ('Call to undefined method : ' . $method);

       array_unshift($args, $this);
       $ret = call_user_func_array(array($this->loadedPlugins[$this->availableMethods[$method]], $method), $args);

       if($ret === false)
          throw new Exception ('Error executing method "' . $method ."'");

       return $ret ;
}
Rich
  • 107
  • 1
  • 13
  • What's the exact line reported by the error message? [call_user_func_array()](http://www.php.net/call_user_func_array) expects 2 arguments, not 3 or 4 (and the array should be the second one anyway). – Álvaro González Mar 20 '19 at 18:00
  • That is the line that is indicated, and yes I agree, there should only be 2 arguments expected. That is why I'm posting. I don't understand that it expects 4 arguments. And yes ever since I have been using this script, it seems the arguments are backwards but it was functioning until now. – Rich Mar 21 '19 at 10:33

0 Answers0