X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FDatabase%2FPostUpdate.php;h=adc88b13e82ec425edc0995724bc3a9bf04ef6bc;hb=79235b6db1c9badd6c9602d54ad0d550e4bec2fd;hp=3ec7822bf037d89f05fe8de53b7dd7ce8a01cd4e;hpb=d7212cbbbcf3f92e6d2935b3b4c596016b8f167d;p=friendica.git diff --git a/src/Database/PostUpdate.php b/src/Database/PostUpdate.php index 3ec7822bf0..adc88b13e8 100644 --- a/src/Database/PostUpdate.php +++ b/src/Database/PostUpdate.php @@ -50,7 +50,7 @@ class PostUpdate // Needed for the helper function to read from the legacy term table const OBJECT_TYPE_POST = 1; - const VERSION = 1452; + const VERSION = 1484; /** * Calls the post update functions @@ -114,6 +114,9 @@ class PostUpdate if (!self::update1483()) { return false; } + if (!self::update1484()) { + return false; + } return true; } @@ -356,7 +359,7 @@ class PostUpdate } } - Tag::store($term['uri-id'], $term['type'], $term['term'], $term['url'], false); + Tag::store($term['uri-id'], $term['type'], $term['term'], $term['url']); $id = $term['tid']; ++$rows; @@ -560,7 +563,7 @@ class PostUpdate $items = DBA::p("SELECT `item`.`id`, `item`.`verb` AS `item-verb`, `item-content`.`verb`, `item-activity`.`activity` FROM `item` LEFT JOIN `item-content` ON `item-content`.`uri-id` = `item`.`uri-id` LEFT JOIN `item-activity` ON `item-activity`.`uri-id` = `item`.`uri-id` AND `item`.`gravity` = ? - WHERE `item`.`id` >= ? AND `item`.`vid` IS NULL ORDER BY `item`.`id` LIMIT 10000", GRAVITY_ACTIVITY, $id); + WHERE `item`.`id` >= ? AND `item`.`vid` IS NULL ORDER BY `item`.`id` LIMIT 10000", Item::GRAVITY_ACTIVITY, $id); if (DBA::errorNo() != 0) { Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]); @@ -1037,6 +1040,11 @@ class PostUpdate return true; } + if (!DBStructure::existsTable('conversation')) { + DI::config()->set('system', 'post_update_version', 1452); + return true; + } + $id = DI::config()->get('system', 'post_update_version_1452_id', 0); Logger::info('Start', ['uri-id' => $id]); @@ -1108,7 +1116,6 @@ class PostUpdate $posts = DBA::select('post-view', ['uri-id'], ['conversation' => './']); while ($post = DBA::fetch($posts)) { - echo $post['uri-id'] . "\n"; $parent = Item::getParent($post['uri-id']); if ($parent != 0) { DBA::update('post', ['parent-uri-id' => $parent], ['uri-id' => $post['uri-id']]); @@ -1121,4 +1128,55 @@ class PostUpdate 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']; + if (is_null($contact['uri-id'])) { + $contact['uri-id'] = ItemURI::getIdByURI($contact['url']); + DBA::update('contact', ['uri-id' => $contact['uri-id']], ['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; + } }