system: finish simplifying plugins_run()

We don't need to mask parameters here.  The providers should
use the same argument count or default parameters if needed.
A single call cannot pass different arguments for different
providers of the same run task.

For most cases a single provider is set anyway or the data is
simple enough.

The reason this code existed was because plugins_run() was once
copied from plugins_configure() which may require this behaviour
but also has no return data.
This commit is contained in:
Franco Fichtner 2023-04-20 12:45:35 +02:00
parent 85116f7bc3
commit 8c9866fdaf

View File

@ -326,25 +326,8 @@ function plugins_run($hook, $args = [])
if (function_exists($func)) {
foreach ($func() as $when => $task) {
if ($hook == $when) {
/*
* An optional argument count parameter can be
* given by the plugin, which allows to securely
* pull more info from the configure call spot.
*/
if (substr_count($task, ':')) {
list($argf, $argc) = explode(':', $task);
} else {
$argf = $task;
$argc = null;
}
if (empty($argc) || !is_numeric($argc)) {
$argc = 1;
}
if ($argc > count($args)) {
$argc = count($args);
}
try {
$result = call_user_func_array($argf, array_slice($args, 0, $argc));
$result = call_user_func_array($task, $args);
if (!empty($result)) {
$ret[$name] = $result;
}