3 use Friendica\Core\Config;
4 use Friendica\Core\Worker;
6 function cronhooks_run(&$argv, &$argc) {
9 require_once 'include/datetime.php';
11 if (($argc == 2) && is_array($a->hooks) && array_key_exists("cron", $a->hooks)) {
12 foreach ($a->hooks["cron"] as $hook) {
13 if ($hook[1] == $argv[1]) {
14 logger("Calling cron hook '" . $hook[1] . "'", LOGGER_DEBUG);
15 call_single_hook($a, $name, $hook, $data);
21 $last = Config::get('system', 'last_cronhook');
23 $poll_interval = intval(Config::get('system', 'cronhook_interval'));
24 if (! $poll_interval) {
29 $next = $last + ($poll_interval * 60);
31 logger('cronhook intervall not reached');
36 $a->set_baseurl(Config::get('system', 'url'));
38 logger('cronhooks: start');
40 $d = datetime_convert();
42 if (is_array($a->hooks) && array_key_exists("cron", $a->hooks)) {
43 foreach ($a->hooks["cron"] as $hook) {
44 logger("Calling cronhooks for '" . $hook[1] . "'", LOGGER_DEBUG);
45 Worker::add(PRIORITY_MEDIUM, "cronhooks", $hook[1]);
49 logger('cronhooks: end');
51 Config::set('system', 'last_cronhook', time());