From 05622d5a933e6d90fb5ac15a06becc6ed0d4e374 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Mon, 22 Apr 2019 20:18:50 +0200 Subject: [PATCH] plugins: plugins_run() has no workers concept "Workers" are chains of commands, but with run we want defined output from the plugin itself so only one function/endpoint returning the data. --- src/etc/inc/plugins.inc | 30 +++++++++++++-------------- src/etc/inc/plugins.inc.d/dpinger.inc | 2 +- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/etc/inc/plugins.inc b/src/etc/inc/plugins.inc index 341fc02b7..6ab9cf09d 100644 --- a/src/etc/inc/plugins.inc +++ b/src/etc/inc/plugins.inc @@ -227,23 +227,21 @@ function plugins_run($hook, $verbose = false, $args = array()) try { include_once $path; } catch (ParseError $e) { error_log($e); } $func = sprintf('%s_run', $name); if (function_exists($func)) { - foreach ($func() as $when => $worker) { - if ($hook == $when && is_array($worker)) { - foreach ($worker as $task) { - /* - * An optional argument count parameter can be - * given by the plugin, which allows to securely - * pull more info from the configure call spot. - */ - list($argf, $argc) = explode(':', $task); - if (empty($argc) || !is_numeric($argc)) { - $argc = 1; - } - if ($argc > count($args)) { - $argc = count($args); - } - $ret[$name] = call_user_func_array($argf, array_slice($args, 0, $argc)); + 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. + */ + list($argf, $argc) = explode(':', $task); + if (empty($argc) || !is_numeric($argc)) { + $argc = 1; } + if ($argc > count($args)) { + $argc = count($args); + } + $ret[$name] = call_user_func_array($argf, array_slice($args, 0, $argc)); } } } diff --git a/src/etc/inc/plugins.inc.d/dpinger.inc b/src/etc/inc/plugins.inc.d/dpinger.inc index 2604056e8..a93d144e3 100644 --- a/src/etc/inc/plugins.inc.d/dpinger.inc +++ b/src/etc/inc/plugins.inc.d/dpinger.inc @@ -301,7 +301,7 @@ function dpinger_configure_do($verbose = false, $gwname = null) function dpinger_run() { return array( - 'return_gateways_status' => array('dpinger_status'), + 'return_gateways_status' => 'dpinger_status', ); }