]> git.mxchange.org Git - friendica.git/blobdiff - src/Worker/Cron.php
Merge pull request #4243 from MrPetovan/task/switch-to-array-new-style
[friendica.git] / src / Worker / Cron.php
index 5814c0548768eba9a17776b4352986825b452a04..e9019216f5b5a798e42197154ca259bb559063dc 100644 (file)
@@ -9,6 +9,8 @@ use Friendica\Core\Worker;
 use Friendica\Database\DBM;
 use dba;
 
+require_once 'include/dba.php';
+
 Class Cron {
        public static function execute($parameter = '', $generation = 0) {
                global $a;
@@ -86,7 +88,7 @@ Class Cron {
                        Worker::add(PRIORITY_LOW, "CronJobs", "update_photo_albums");
 
                        // Delete all done workerqueue entries
-                       dba::delete('workerqueue', array('`done` AND `executed` < UTC_TIMESTAMP() - INTERVAL 12 HOUR'));
+                       dba::delete('workerqueue', ['`done` AND `executed` < UTC_TIMESTAMP() - INTERVAL 12 HOUR']);
 
                        // check upstream version?
                        Worker::add(PRIORITY_LOW, 'CheckVersion');
@@ -153,14 +155,13 @@ Class Cron {
                        : ''
                );
 
-               $contacts = q("SELECT `contact`.`id`, `contact`.`nick`, `contact`.`name`, `contact`.`network`,
-                                       `contact`.`last-update`, `contact`.`priority`, `contact`.`subhub`
+               $contacts = q("SELECT `contact`.`id`, `contact`.`nick`, `contact`.`name`, `contact`.`network`, `contact`.`archive`,
+                                       `contact`.`last-update`, `contact`.`priority`, `contact`.`rel`, `contact`.`subhub`
                                FROM `user`
                                STRAIGHT_JOIN `contact`
                                ON `contact`.`uid` = `user`.`uid` AND `contact`.`poll` != ''
                                        AND `contact`.`network` IN ('%s', '%s', '%s', '%s', '%s') $sql_extra
-                                       AND NOT `contact`.`self` AND NOT `contact`.`blocked` AND NOT `contact`.`readonly`
-                                       AND NOT `contact`.`archive`
+                                       AND NOT `contact`.`self` AND NOT `contact`.`blocked`
                                WHERE NOT `user`.`account_expired` AND NOT `user`.`account_removed` $abandon_sql",
                        dbesc(NETWORK_DFRN),
                        dbesc(NETWORK_OSTATUS),
@@ -179,11 +180,12 @@ Class Cron {
                                $contact['last-update'] = NULL_DATE;
                        }
 
-                       if (in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS))) {
+                       // Friendica and OStatus are checked once a day
+                       if (in_array($contact['network'], [NETWORK_DFRN, NETWORK_OSTATUS])) {
                                $contact['priority'] = 2;
                        }
 
-                       if ($contact['subhub'] && in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS))) {
+                       if ($contact['subhub'] && in_array($contact['network'], [NETWORK_DFRN, 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)
@@ -191,7 +193,17 @@ Class Cron {
                                 * 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);
+                               $contact['priority'] = (!is_null($poll_interval) ? intval($poll_interval) : 3);
+                       }
+
+                       // Check Diaspora contacts or followers once a week
+                       if (($contact["network"] == NETWORK_DIASPORA) || ($contact["rel"] == CONTACT_IS_FOLLOWER)) {
+                               $contact['priority'] = 4;
+                       }
+
+                       // Check archived contacts once a month
+                       if ($contact['archive']) {
+                               $contact['priority'] = 5;
                        }
 
                        if (($contact['priority'] >= 0) && !$force) {
@@ -240,14 +252,17 @@ Class Cron {
                                }
                        }
 
-                       logger("Polling " . $contact["network"] . " " . $contact["id"] . " " . $contact["nick"] . " " . $contact["name"]);
-
                        if (($contact['network'] == NETWORK_FEED) && ($contact['priority'] <= 3)) {
                                $priority = PRIORITY_MEDIUM;
+                       } elseif ($contact['archive']) {
+                               $priority = PRIORITY_NEGLIGIBLE;
                        } else {
                                $priority = PRIORITY_LOW;
                        }
-                       Worker::add(array('priority' => $priority, 'dont_fork' => true), 'OnePoll', (int)$contact['id']);
+
+                       logger("Polling " . $contact["network"] . " " . $contact["id"] . " " . $contact['priority'] . " " . $contact["nick"] . " " . $contact["name"]);
+
+                       Worker::add(['priority' => $priority, 'dont_fork' => true], 'OnePoll', (int)$contact['id']);
                }
        }
 }