Skip to content

Commit

Permalink
catch ArgumentCountError and return XML error message for remoteAPI, f…
Browse files Browse the repository at this point in the history
…ixes #2545

This is caused by a PHP 7.1 change:
https://www.php.net/manual/en/migration71.incompatible.php
#migration71.incompatible.too-few-arguments-exception

Previously call_user_func_array will make those missing arguments
to NULL without throwing an exception.
  • Loading branch information
phy25 committed Mar 3, 2020
1 parent a9284ce commit e1215f1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions inc/Remote/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,11 @@ private function callPlugin($pluginName, $method, $args)
}
$this->checkAccess($methods[$method]);
$name = $this->getMethodName($methods, $method);
return call_user_func_array(array($plugin, $name), $args);
try {
return call_user_func_array(array($plugin, $name), $args);
} catch (\ArgumentCountError $th) {
throw new RemoteException('Method does not exist - wrong parameter count.', -32603);
}
}

/**
Expand All @@ -185,7 +189,11 @@ private function callCoreMethod($method, $args)
throw new RemoteException('Method does not exist', -32603);
}
$this->checkArgumentLength($coreMethods[$method], $args);
return call_user_func_array(array($this->coreMethods, $this->getMethodName($coreMethods, $method)), $args);
try {
return call_user_func_array(array($this->coreMethods, $this->getMethodName($coreMethods, $method)), $args);
} catch (\ArgumentCountError $th) {
throw new RemoteException('Method does not exist - wrong parameter count.', -32603);
}
}

/**
Expand Down

0 comments on commit e1215f1

Please sign in to comment.