3 * @file src/Worker/CronHooks.php
6 namespace Friendica\Worker;
8 use Friendica\Core\Addon;
9 use Friendica\Core\Config;
10 use Friendica\Core\Worker;
11 use Friendica\Util\DateTimeFormat;
14 public static function execute($hook = '') {
17 require_once 'include/datetime.php';
19 if (($hook != '') && is_array($a->hooks) && array_key_exists("cron", $a->hooks)) {
20 foreach ($a->hooks["cron"] as $single_hook) {
21 if ($single_hook[1] == $hook) {
22 logger("Calling cron hook '" . $hook . "'", LOGGER_DEBUG);
23 Addon::callSingleHook($a, $hook, $single_hook);
29 $last = Config::get('system', 'last_cronhook');
31 $poll_interval = intval(Config::get('system', 'cronhook_interval'));
32 if (!$poll_interval) {
37 $next = $last + ($poll_interval * 60);
39 logger('cronhook intervall not reached');
44 $a->set_baseurl(Config::get('system', 'url'));
46 logger('cronhooks: start');
48 $d = DateTimeFormat::utcNow();
50 if (is_array($a->hooks) && array_key_exists("cron", $a->hooks)) {
51 foreach ($a->hooks["cron"] as $hook) {
52 logger("Calling cronhooks for '" . $hook[1] . "'", LOGGER_DEBUG);
53 Worker::add(PRIORITY_MEDIUM, "CronHooks", $hook[1]);
57 logger('cronhooks: end');
59 Config::set('system', 'last_cronhook', time());