Only run JSON hooks when $sAction is set #755

This commit is contained in:
the-djmaze 2022-12-07 16:26:38 +01:00
parent b679cb41d9
commit 40cf942ddd

View file

@ -151,15 +151,15 @@ class ServiceActions
if (\method_exists($this->oActions, $sMethodName) &&
\is_callable(array($this->oActions, $sMethodName)))
{
$this->Plugins()->RunHook('json.action-pre-call', array($sAction));
$sAction && $this->Plugins()->RunHook('json.action-pre-call', array($sAction));
$aResponseItem = $this->oActions->{$sMethodName}();
$this->Plugins()->RunHook('json.action-post-call', array($sAction, &$aResponseItem));
$sAction && $this->Plugins()->RunHook('json.action-post-call', array($sAction, &$aResponseItem));
}
else if ($this->Plugins()->HasAdditionalJson($sMethodName))
{
$this->Plugins()->RunHook('json.action-pre-call', array($sAction));
$sAction && $this->Plugins()->RunHook('json.action-pre-call', array($sAction));
$aResponseItem = $this->Plugins()->RunAdditionalJson($sMethodName);
$this->Plugins()->RunHook('json.action-post-call', array($sAction, &$aResponseItem));
$sAction && $this->Plugins()->RunHook('json.action-post-call', array($sAction, &$aResponseItem));
}
}
@ -184,7 +184,7 @@ class ServiceActions
$aResponseItem['Time'] = (int) ((\microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']) * 1000);
}
$this->Plugins()->RunHook('filter.json-response', array($sAction, &$aResponseItem));
$sAction && $this->Plugins()->RunHook('filter.json-response', array($sAction, &$aResponseItem));
if (!\headers_sent()) {
\header('Content-Type: application/json; charset=utf-8');