X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FWorker%2FCron.php;h=db0d518cc3612bd40d71ada7e492a8aab82ed5b6;hb=b9387c0a638b344f0c30b21575599bffa6966582;hp=c859824755a1a5ee79ff12b6fbd3b10c98874dc2;hpb=405753d1c335cfda94bdf1c8799f7e7b3e94a177;p=friendica.git diff --git a/src/Worker/Cron.php b/src/Worker/Cron.php index c859824755..db0d518cc3 100644 --- a/src/Worker/Cron.php +++ b/src/Worker/Cron.php @@ -1,9 +1,13 @@ = 0) && !$force) { + $update = false; + + $t = $contact['last-update']; + + /* + * Based on $contact['priority'], should we poll this site now? Or later? + */ + switch ($contact['priority']) { + case 5: + if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', $t . " + 1 month")) { + $update = true; + } + break; + case 4: + if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', $t . " + 1 week")) { + $update = true; + } + break; + case 3: + if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', $t . " + 1 day")) { + $update = true; + } + break; + case 2: + if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', $t . " + 12 hour")) { + $update = true; + } + break; + case 1: + 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 ($contact['subhub'] && in_array($contact['network'], array(NETWORK_DFRN, NETWORK_ZOT, NETWORK_OSTATUS))) { - /* - * We should be getting everything via a hub. But just to be sure, let's check once a day. - * (You can make this more or less frequent if desired by setting 'pushpoll_frequency' appropriately) - * This also lets us update our subscription to the hub, and add or replace hubs in case it - * changed. We will only update hubs once a day, regardless of 'pushpoll_frequency'. - */ - $poll_interval = Config::get('system', 'pushpoll_frequency'); - $contact['priority'] = (($poll_interval !== false) ? intval($poll_interval) : 3); + if (!$update) { + continue; } + } - if (($contact['priority'] >= 0) && !$force) { - $update = false; - - $t = $contact['last-update']; - - /* - * Based on $contact['priority'], should we poll this site now? Or later? - */ - switch ($contact['priority']) { - case 5: - if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', $t . " + 1 month")) { - $update = true; - } - break; - case 4: - if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', $t . " + 1 week")) { - $update = true; - } - break; - case 3: - if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', $t . " + 1 day")) { - $update = true; - } - break; - case 2: - if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', $t . " + 12 hour")) { - $update = true; - } - break; - case 1: - 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; - } - } + if (($contact['network'] == NETWORK_FEED) && ($contact['priority'] <= 3)) { + $priority = PRIORITY_MEDIUM; + } elseif ($contact['archive']) { + $priority = PRIORITY_NEGLIGIBLE; + } else { + $priority = PRIORITY_LOW; + } - logger("Polling " . $contact["network"] . " " . $contact["id"] . " " . $contact["nick"] . " " . $contact["name"]); + logger("Polling " . $contact["network"] . " " . $contact["id"] . " " . $contact['priority'] . " " . $contact["nick"] . " " . $contact["name"]); - if (($contact['network'] == NETWORK_FEED) && ($contact['priority'] <= 3)) { - $priority = PRIORITY_MEDIUM; - } else { - $priority = PRIORITY_LOW; - } - Worker::add(array('priority' => $priority, 'dont_fork' => true), 'OnePoll', (int)$contact['id']); - } + Worker::add(array('priority' => $priority, 'dont_fork' => true), 'OnePoll', (int)$contact['id']); } } }