Merge pull request #6108 from annando/fork-check

Add some hook to check if hook should be forked
This commit is contained in:
Hypolite Petovan 2018-11-10 20:56:42 -05:00 committed by GitHub
commit a30876977d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -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

View File

@ -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);
}
}