]> git.mxchange.org Git - friendica.git/blobdiff - src/Worker/UpdateContacts.php
Use a constant for the avatar base path
[friendica.git] / src / Worker / UpdateContacts.php
index ba4f9db41c8f32482c93097f79a151bc0253dee8..2beb890918538373c87a2e647ba567638da8cba9 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -52,18 +52,20 @@ class UpdateContacts
                $condition = DBA::mergeConditions($base_condition,
                        ["`uid` != ? AND (`last-update` < ? OR (NOT `failed` AND `last-update` < ?))",
                        0, DateTimeFormat::utc('now - 1 month'), DateTimeFormat::utc('now - 1 week')]);
-               $ids = self::getContactsToUpdate($condition, [], $limit);
+               $ids = self::getContactsToUpdate($condition, $limit, []);
                Logger::info('Fetched federated user contacts', ['count' => count($ids)]);
 
-               $conditions = ["`id` IN (SELECT `author-id` FROM `post-user`)", "`id` IN (SELECT `owner-id` FROM `post-user`)", 
-                       "`id` IN (SELECT `causer-id` FROM `post-user`)", "`id` IN (SELECT `cid` FROM `post-tag`)",
-                       "`id` IN (SELECT `cid` FROM `user-contact`)"];
+               $conditions = ["`id` IN (SELECT `author-id` FROM `post` WHERE `author-id` = `contact`.`id`)",
+                       "`id` IN (SELECT `owner-id` FROM `post` WHERE `owner-id` = `contact`.`id`)",
+                       "`id` IN (SELECT `causer-id` FROM `post` WHERE `causer-id` = `contact`.`id`)",
+                       "`id` IN (SELECT `cid` FROM `post-tag` WHERE `cid` = `contact`.`id`)",
+                       "`id` IN (SELECT `cid` FROM `user-contact` WHERE `cid` = `contact`.`id`)"];
 
                foreach ($conditions as $contact_condition) {
                        $condition = DBA::mergeConditions($base_condition,
                                [$contact_condition . " AND (`last-update` < ? OR (NOT `failed` AND `last-update` < ?))",
                                DateTimeFormat::utc('now - 1 month'), DateTimeFormat::utc('now - 1 week')]);
-                       $ids = self::getContactsToUpdate($condition, $ids, $limit);
+                       $ids = self::getContactsToUpdate($condition, $limit, $ids);
                        Logger::info('Fetched interacting federated contacts', ['count' => count($ids), 'condition' => $contact_condition]);
                }
 
@@ -78,7 +80,7 @@ class UpdateContacts
                                ["(`last-update` < ? OR (NOT `failed` AND `last-update` < ?))",
                                        DateTimeFormat::utc('now - 6 month'), DateTimeFormat::utc('now - 1 month')]);
                        $previous = count($ids);
-                       $ids = self::getContactsToUpdate($condition, $ids, $limit - $previous);
+                       $ids = self::getContactsToUpdate($condition, $limit - $previous, $ids);
                        Logger::info('Fetched federated contacts', ['count' => count($ids) - $previous]);
                }
 
@@ -96,10 +98,11 @@ class UpdateContacts
         * Returns contact ids based on a given condition
         *
         * @param array $condition
+        * @param int $limit
         * @param array $ids
         * @return array contact ids
         */
-       private static function getContactsToUpdate(array $condition, array $ids = [], int $limit)
+       private static function getContactsToUpdate(array $condition, int $limit, array $ids = [])
        {
                $contacts = DBA::select('contact', ['id'], $condition, ['limit' => $limit]);
                while ($contact = DBA::fetch($contacts)) {