From 6c90005363c7164956501c044cc4f7a449317ff5 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 29 May 2021 21:28:40 +0000 Subject: [PATCH 1/2] Issue 9923: Fix DB Error 1055 --- src/Module/Search/Index.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Module/Search/Index.php b/src/Module/Search/Index.php index 2fda994caa..1a7d4bf61f 100644 --- a/src/Module/Search/Index.php +++ b/src/Module/Search/Index.php @@ -170,8 +170,10 @@ class Index extends BaseSearch } if (!empty($uriids)) { - $params = ['order' => ['id' => true], 'group_by' => ['uri-id']]; - $items = Post::toArray(Post::selectForUser(local_user(), Item::DISPLAY_FIELDLIST, ['uri-id' => $uriids], $params)); + $condition = ["(`uid` = ? OR (`uid` = ? AND NOT `global`))", 0, local_user()]; + $condition = DBA::mergeConditions($condition, ['uri-id' => $uriids]); + $params = ['order' => ['id' => true]]; + $items = Post::toArray(Post::selectForUser(local_user(), Item::DISPLAY_FIELDLIST, $condition, $params)); } if (empty($items)) { From 4cdfcb5cfb017142ce73f52b970190d76d068ff8 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 29 May 2021 21:51:33 +0000 Subject: [PATCH 2/2] Avoid DB Errors with "group by" --- src/Worker/ExpirePosts.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Worker/ExpirePosts.php b/src/Worker/ExpirePosts.php index 3f1075db5d..3659edfdee 100644 --- a/src/Worker/ExpirePosts.php +++ b/src/Worker/ExpirePosts.php @@ -119,7 +119,7 @@ class ExpirePosts Logger::notice('Adding missing entries'); $rows = 0; - $userposts = DBA::select('post-user', [], ["`uri-id` not in (select `uri-id` from `post`)"], ['group_by' => ['uri-id']]); + $userposts = DBA::select('post-user', [], ["`uri-id` not in (select `uri-id` from `post`)"]); while ($fields = DBA::fetch($userposts)) { $post_fields = DBStructure::getFieldsForTable('post', $fields); DBA::insert('post', $post_fields, Database::INSERT_IGNORE); @@ -133,7 +133,7 @@ class ExpirePosts } $rows = 0; - $userposts = DBA::select('post-user', [], ["`gravity` = ? AND `uri-id` not in (select `uri-id` from `post-thread`)", GRAVITY_PARENT], ['group_by' => ['uri-id']]); + $userposts = DBA::select('post-user', [], ["`gravity` = ? AND `uri-id` not in (select `uri-id` from `post-thread`)", GRAVITY_PARENT]); while ($fields = DBA::fetch($userposts)) { $post_fields = DBStructure::getFieldsForTable('post-thread', $fields); $post_fields['commented'] = $post_fields['changed'] = $post_fields['created'];