]> git.mxchange.org Git - friendica.git/blobdiff - include/cron.php
Merge pull request #2016 from fabrixxm/template_vars_hook
[friendica.git] / include / cron.php
index ea7fd2c6060606c9d61a18f8ec97c96d5fa8cbe6..46067d76da05f88c10b4173c212466abee82c7e0 100644 (file)
@@ -52,6 +52,20 @@ function cron_run(&$argv, &$argc){
                }
        }
 
+       $last = get_config('system','last_cron');
+
+       $poll_interval = intval(get_config('system','cron_interval'));
+       if(! $poll_interval)
+               $poll_interval = 10;
+
+       if($last) {
+               $next = $last + ($poll_interval * 60);
+               if($next > time()) {
+                       logger('cron intervall not reached');
+                       return;
+               }
+       }
+
        $lockpath = get_lockpath();
        if ($lockpath != '') {
                $pidfile = new pidfile($lockpath, 'cron');
@@ -75,6 +89,22 @@ function cron_run(&$argv, &$argc){
 
        logger('cron: start');
 
+       // run queue delivery process in the background
+
+       proc_run('php',"include/queue.php");
+
+       // run diaspora photo queue process in the background
+
+       proc_run('php',"include/dsprphotoq.php");
+
+       // run the process to discover global contacts in the background
+
+       proc_run('php',"include/discover_poco.php");
+
+       // run the process to update locally stored global contacts in the background
+
+       proc_run('php',"include/discover_poco.php", "checkcontact");
+
        // expire any expired accounts
 
        q("UPDATE user SET `account_expired` = 1 where `account_expired` = 0
@@ -185,15 +215,16 @@ function cron_run(&$argv, &$argc){
        if(! $interval)
                $interval = ((get_config('system','delivery_interval') === false) ? 3 : intval(get_config('system','delivery_interval')));
 
+       // If we are using the worker we don't need a delivery interval
+       if (get_config("system", "worker"))
+               $interval = false;
+
        $sql_extra = (($manual_id) ? " AND `id` = $manual_id " : "");
 
        reload_plugins();
 
        $d = datetime_convert();
 
-       if(! $restart)
-               proc_run('php','include/cronhooks.php');
-
        // Only poll from those with suitable relationships,
        // and which have a polling address and ignore Diaspora since
        // we are unable to match those posts with a Diaspora GUID and prevent duplicates.
@@ -299,10 +330,12 @@ function cron_run(&$argv, &$argc){
 
        logger('cron: end');
 
+       set_config('system','last_cron', time());
+
        return;
 }
 
 if (array_search(__file__,get_included_files())===0){
-  cron_run($_SERVER["argv"],$_SERVER["argc"]);
-  killme();
+       cron_run($_SERVER["argv"],$_SERVER["argc"]);
+       killme();
 }