]> git.mxchange.org Git - friendica.git/commitdiff
Improve SQL-Queries / fixed "fetch_parents" setting
authorMichael <heluecht@pirati.ca>
Mon, 8 Aug 2022 20:00:21 +0000 (20:00 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 8 Aug 2022 20:00:21 +0000 (20:00 +0000)
src/Protocol/ActivityPub/Processor.php
src/Worker/RemoveUnusedAvatars.php
src/Worker/RemoveUnusedContacts.php
src/Worker/UpdateContacts.php

index 7b2f2ab0c80bf3ea44818398bec2c6c3afccee0f..f142b7e91d148070b0234ef5de97c2923900c028 100644 (file)
@@ -345,7 +345,7 @@ class Processor
                        return [];
                }
 
-               if (!in_array(0, $activity['receiver']) && !DI::config()->get('system', 'fetch_parents')) {
+               if (!in_array(0, $activity['receiver']) || !DI::config()->get('system', 'fetch_parents')) {
                        $fetch_parents = false;
                }
 
index da9ca7b04e48298b937d9f9708a4a239e38bc107..8adc7d76de22167cc08ab5f106ab2faa0acd4c3a 100644 (file)
@@ -39,7 +39,7 @@ class RemoveUnusedAvatars
                                AND NOT `nurl` IN (SELECT `nurl` FROM `contact` WHERE `uid` != ?)
                                AND NOT `contact`.`id` IN (SELECT `author-id` FROM `post-user`)
                                AND NOT `contact`.`id` IN (SELECT `owner-id` FROM `post-user`)
-                               AND NOT `contact`.`id` IN (SELECT `causer-id` FROM `post-user`)
+                               AND NOT `contact`.`id` IN (SELECT `causer-id` FROM `post-user` WHERE `causer-id` IS NOT NULL)
                                AND NOT `contact`.`id` IN (SELECT `cid` FROM `post-tag`)
                                AND NOT `contact`.`id` IN (SELECT `contact-id` FROM `post-user`);";
 
index 850760254a7544003d210fa0d258d80ab063ba77..324ec2419f144584cf2772135b51e042941bc4b3 100644 (file)
@@ -40,7 +40,7 @@ class RemoveUnusedContacts
                $condition = ["`id` != ? AND `uid` = ? AND NOT `self` AND NOT `nurl` IN (SELECT `nurl` FROM `contact` WHERE `uid` != ?)
                        AND (NOT `network` IN (?, ?, ?, ?, ?, ?) OR (`archive` AND `success_update` < ?))
                        AND NOT `id` IN (SELECT `author-id` FROM `post-user`) AND NOT `id` IN (SELECT `owner-id` FROM `post-user`)
-                       AND NOT `id` IN (SELECT `causer-id` FROM `post-user`) AND NOT `id` IN (SELECT `cid` FROM `post-tag`)
+                       AND NOT `id` IN (SELECT `causer-id` FROM `post-user` WHERE `causer-id` IS NOT NULL) AND NOT `id` IN (SELECT `cid` FROM `post-tag`)
                        AND NOT `id` IN (SELECT `contact-id` FROM `post-user`) AND NOT `id` IN (SELECT `cid` FROM `user-contact`)
                        AND NOT `id` IN (SELECT `cid` FROM `event`) AND NOT `id` IN (SELECT `contact-id` FROM `group_member`)
                        AND `created` < ?",
index 9dc0bacca712984f75c83de20e42413000b19bd9..d5fe2f2079eaca828d9b6331d43efc3e37a0c41c 100644 (file)
@@ -55,11 +55,11 @@ class UpdateContacts
                $ids = self::getContactsToUpdate($condition, $limit, []);
                Logger::info('Fetched federated user contacts', ['count' => count($ids)]);
 
-               $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`)"];
+               $conditions = ["`id` IN (SELECT `author-id` FROM `post`)",
+                       "`id` IN (SELECT `owner-id` FROM `post`)",
+                       "`id` IN (SELECT `causer-id` FROM `post` WHERE NOT `causer-id` IS NULL)",
+                       "`id` IN (SELECT `cid` FROM `post-tag`)",
+                       "`id` IN (SELECT `cid` FROM `user-contact`)"];
 
                foreach ($conditions as $contact_condition) {
                        $condition = DBA::mergeConditions($base_condition,