aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Extend/Hook.php10
-rwxr-xr-xinclude/plugin.php15
2 files changed, 23 insertions, 2 deletions
diff --git a/Zotlabs/Extend/Hook.php b/Zotlabs/Extend/Hook.php
index 836b29db8..edfacfa3b 100644
--- a/Zotlabs/Extend/Hook.php
+++ b/Zotlabs/Extend/Hook.php
@@ -6,6 +6,10 @@ namespace Zotlabs\Extend;
class Hook {
static public function register($hook,$file,$function,$version = 1,$priority = 0) {
+ if(is_array($function)) {
+ $function = serialize($function);
+ }
+
$r = q("SELECT * FROM `hook` WHERE `hook` = '%s' AND `file` = '%s' AND `function` = '%s' and priority = %d and hook_version = %d LIMIT 1",
dbesc($hook),
dbesc($file),
@@ -28,6 +32,9 @@ class Hook {
}
static public function unregister($hook,$file,$function,$version = 1,$priority = 0) {
+ if(is_array($function)) {
+ $function = serialize($function);
+ }
$r = q("DELETE FROM hook WHERE hook = '%s' AND `file` = '%s' AND `function` = '%s' and priority = %d and hook_version = %d",
dbesc($hook),
dbesc($file),
@@ -63,6 +70,9 @@ class Hook {
*/
static public function insert($hook, $fn, $version = 0, $priority = 0) {
+ if(is_array($fn)) {
+ $fn = serialize($fn);
+ }
if(! is_array(App::$hooks))
App::$hooks = array();
diff --git a/include/plugin.php b/include/plugin.php
index 80e3ae20e..8dd67bb0c 100755
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -282,10 +282,21 @@ function call_hooks($name, &$data = null) {
$a = 0;
if((is_array(App::$hooks)) && (array_key_exists($name, App::$hooks))) {
foreach(App::$hooks[$name] as $hook) {
+ $origfn = $hook[1];
if($hook[0])
@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(function_exists($hook[1])) {
+ if(is_callable($hook[1])) {
$func = $hook[1];
if($hook[3])
$func($data);
@@ -295,7 +306,7 @@ function call_hooks($name, &$data = null) {
q("DELETE FROM hook WHERE hook = '%s' AND file = '%s' AND function = '%s'",
dbesc($name),
dbesc($hook[0]),
- dbesc($hook[1])
+ dbesc($origfn)
);
}
}