mirror of
https://github.com/friendica/friendica
synced 2024-12-23 04:40:15 +00:00
Merge pull request #6108 from annando/fork-check
Add some hook to check if hook should be forked
This commit is contained in:
commit
a30876977d
2 changed files with 19 additions and 0 deletions
|
@ -693,6 +693,9 @@ Here is a complete list of all hook callbacks with file locations (as of 24-Sep-
|
|||
|
||||
Addon::callHooks('logged_in', $a->user);
|
||||
|
||||
### src/Core/Hook.php
|
||||
|
||||
self::callSingle(self::getApp(), 'hook_fork', $fork_hook, $hookdata);
|
||||
|
||||
### src/Core/Worker.php
|
||||
|
||||
|
|
|
@ -136,6 +136,22 @@ class Hook extends BaseObject
|
|||
{
|
||||
if (array_key_exists($name, self::$hooks)) {
|
||||
foreach (self::$hooks[$name] as $hook) {
|
||||
// Call a hook to check if this hook call needs to be forked
|
||||
if (array_key_exists('hook_fork', self::$hooks)) {
|
||||
$hookdata = ['name' => $name, 'data' => $data, 'execute' => true];
|
||||
|
||||
foreach (self::$hooks['hook_fork'] as $fork_hook) {
|
||||
if ($hook[0] != $fork_hook[0]) {
|
||||
continue;
|
||||
}
|
||||
self::callSingle(self::getApp(), 'hook_fork', $fork_hook, $hookdata);
|
||||
}
|
||||
|
||||
if (!$hookdata['execute']) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Worker::add($priority, 'ForkHook', $name, $hook, $data);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue