+
+ /**
+ * Correct the parent.
+ * This fixes a bug that was introduced in the development of version 2022.09
+ *
+ * @return bool "true" when the job is done
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
+ */
+ private static function update1483()
+ {
+ // Was the script completed?
+ if (DI::config()->get('system', 'post_update_version') >= 1483) {
+ return true;
+ }
+
+ Logger::info('Start');
+
+ $posts = DBA::select('post-view', ['uri-id'], ['conversation' => './']);
+ while ($post = DBA::fetch($posts)) {
+ $parent = Item::getParent($post['uri-id']);
+ if ($parent != 0) {
+ DBA::update('post', ['parent-uri-id' => $parent], ['uri-id' => $post['uri-id']]);
+ DBA::update('post-user', ['parent-uri-id' => $parent], ['uri-id' => $post['uri-id']]);
+ }
+ }
+ DBA::close($posts);
+
+ DI::config()->set('system', 'post_update_version', 1483);
+ Logger::info('Done');
+ return true;
+ }
+
+ /**
+ * Handle duplicate contact entries
+ *
+ * @return bool "true" when the job is done
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
+ */
+ private static function update1484()
+ {
+ // Was the script completed?
+ if (DI::config()->get('system', 'post_update_version') >= 1484) {
+ return true;
+ }
+
+ $id = DI::config()->get('system', 'post_update_version_1484_id', 0);
+
+ Logger::info('Start', ['id' => $id]);
+
+ $rows = 0;
+
+ $contacts = DBA::select('contact', ['id', 'uid', 'uri-id', 'url'], ["`id` > ?", $id], ['order' => ['id'], 'limit' => 1000]);
+
+ if (DBA::errorNo() != 0) {
+ Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
+ return false;
+ }
+
+ while ($contact = DBA::fetch($contacts)) {
+ $id = $contact['id'];
+ Contact::setAccountUser($contact['id'], $contact['uid'], $contact['uri-id'], $contact['url']);
+ ++$rows;
+ }
+ DBA::close($contacts);
+
+ DI::config()->set('system', 'post_update_version_1484_id', $id);
+
+ Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
+
+ if ($rows <= 100) {
+ DI::config()->set('system', 'post_update_version', 1484);
+ Logger::info('Done');
+ return true;
+ }
+
+ return false;
+ }