From: Michael Date: Mon, 8 Aug 2022 20:00:21 +0000 (+0000) Subject: Improve SQL-Queries / fixed "fetch_parents" setting X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=548b7f43a5f22fa4eea917de1ed3de7588ac294d;p=friendica.git Improve SQL-Queries / fixed "fetch_parents" setting --- diff --git a/src/Protocol/ActivityPub/Processor.php b/src/Protocol/ActivityPub/Processor.php index 7b2f2ab0c8..f142b7e91d 100644 --- a/src/Protocol/ActivityPub/Processor.php +++ b/src/Protocol/ActivityPub/Processor.php @@ -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; } diff --git a/src/Worker/RemoveUnusedAvatars.php b/src/Worker/RemoveUnusedAvatars.php index da9ca7b04e..8adc7d76de 100644 --- a/src/Worker/RemoveUnusedAvatars.php +++ b/src/Worker/RemoveUnusedAvatars.php @@ -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`);"; diff --git a/src/Worker/RemoveUnusedContacts.php b/src/Worker/RemoveUnusedContacts.php index 850760254a..324ec2419f 100644 --- a/src/Worker/RemoveUnusedContacts.php +++ b/src/Worker/RemoveUnusedContacts.php @@ -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` < ?", diff --git a/src/Worker/UpdateContacts.php b/src/Worker/UpdateContacts.php index 9dc0bacca7..d5fe2f2079 100644 --- a/src/Worker/UpdateContacts.php +++ b/src/Worker/UpdateContacts.php @@ -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,