aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2024-06-14 16:31:42 +0200
committerHarald Eilertsen <haraldei@anduin.net>2024-06-14 16:43:38 +0200
commit1ed8383c33530b221ef34ad1c5e9b3b80eab94fa (patch)
treecd74a3515c4ef058f1cf72bc3737300358b24ec7 /include
parentd139f2fe87eef3b863b0cbbe810c9bde92fb3ec5 (diff)
downloadvolse-hubzilla-1ed8383c33530b221ef34ad1c5e9b3b80eab94fa.tar.gz
volse-hubzilla-1ed8383c33530b221ef34ad1c5e9b3b80eab94fa.tar.bz2
volse-hubzilla-1ed8383c33530b221ef34ad1c5e9b3b80eab94fa.zip
Allow passing callable as array to hooks.
Diffstat (limited to 'include')
-rw-r--r--include/plugin.php21
1 files changed, 11 insertions, 10 deletions
diff --git a/include/plugin.php b/include/plugin.php
index 4601cb544..62b643c3e 100644
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -488,18 +488,19 @@ function call_hooks($name, &$data = null) {
@include_once($hook[0]);
}
- if(preg_match('|^a:[0-9]+:{.*}$|s', $hook[1])) {
- $hook[1] = unserialize($hook[1]);
- }
- elseif(strpos($hook[1],'::')) {
- // We shouldn't need to do this, but it appears that PHP
- // isn't able to directly execute a string variable with a class
- // method in the manner we are attempting it, so we'll
- // turn it into an array.
- $hook[1] = explode('::',$hook[1]);
+ if(is_string($hook[1])) {
+ if (preg_match('|^a:[0-9]+:{.*}$|s', $hook[1])) {
+ $hook[1] = unserialize($hook[1]);
+ }
+ elseif(strpos($hook[1],'::')) {
+ // We shouldn't need to do this, but it appears that PHP
+ // isn't able to directly execute a string variable with a class
+ // method in the manner we are attempting it, so we'll
+ // turn it into an array.
+ $hook[1] = explode('::',$hook[1]);
+ }
}
-
if(is_callable($hook[1])) {
$func = $hook[1];
$func($data);