]> git.mxchange.org Git - friendica.git/blobdiff - include/cron.php
The index mustn't be 192 characters long
[friendica.git] / include / cron.php
index a2af016961e4d2b811b2eaf2c57a2f983f72c262..70b87e969618cac8dbbbc9b87a727e8e657e81cc 100644 (file)
@@ -1,5 +1,6 @@
 <?php
-use \Friendica\Core\Config;
+
+use Friendica\Core\Config;
 
 function cron_run(&$argv, &$argc){
        global $a;
@@ -64,7 +65,7 @@ function cron_run(&$argv, &$argc){
 
        // once daily run birthday_updates and then expire in background
        $d1 = get_config('system', 'last_expire_day');
-       $d2 = intval(datetime_convert('UTC','UTC','now','d'));
+       $d2 = intval(datetime_convert('UTC', 'UTC', 'now', 'd'));
 
        if ($d2 != intval($d1)) {
 
@@ -74,7 +75,7 @@ function cron_run(&$argv, &$argc){
 
                proc_run(PRIORITY_LOW, "include/discover_poco.php", "suggestions");
 
-               set_config('system', 'last_expire_day',$d2);
+               set_config('system', 'last_expire_day', $d2);
 
                proc_run(PRIORITY_LOW, 'include/expire.php');
 
@@ -121,6 +122,8 @@ function cron_poll_contacts($argc, $argv) {
                $force     = true;
        }
 
+       $min_poll_interval = Config::get('system', 'min_poll_interval', 1);
+
        $sql_extra = (($manual_id) ? " AND `id` = $manual_id " : "");
 
        reload_plugins();
@@ -194,7 +197,7 @@ function cron_poll_contacts($argc, $argv) {
                                $contact['priority'] = (($poll_interval !== false) ? intval($poll_interval) : 3);
                        }
 
-                       if ($contact['priority'] AND !$force) {
+                       if (($contact['priority'] >= 0) AND !$force) {
                                $update = false;
 
                                $t = $contact['last-update'];
@@ -224,11 +227,16 @@ function cron_poll_contacts($argc, $argv) {
                                                }
                                                break;
                                        case 1:
-                                       default:
                                                if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', $t . " + 1 hour")) {
                                                        $update = true;
                                                }
                                                break;
+                                       case 0:
+                                       default:
+                                               if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', $t . " + ".$min_poll_interval." minute")) {
+                                                       $update = true;
+                                               }
+                                               break;
                                }
                                if (!$update) {
                                        continue;
@@ -238,10 +246,11 @@ function cron_poll_contacts($argc, $argv) {
                        logger("Polling " . $contact["network"] . " " . $contact["id"] . " " . $contact["nick"] . " " . $contact["name"]);
 
                        if (($contact['network'] == NETWORK_FEED) AND ($contact['priority'] <= 3)) {
-                               proc_run(PRIORITY_MEDIUM, 'include/onepoll.php', intval($contact['id']));
+                               $priority = PRIORITY_MEDIUM;
                        } else {
-                               proc_run(PRIORITY_LOW, 'include/onepoll.php', intval($contact['id']));
+                               $priority = PRIORITY_LOW;
                        }
+                       proc_run(array('priority' => $priority, 'dont_fork' => true), 'include/onepoll.php', intval($contact['id']));
                }
        }
 }