X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FDatabase%2FPostUpdate.php;h=acc98c882c77b7cc27ba34cbf2df8bab7600cdc9;hb=3b173f2007dd955644372b9f795cf3850f33546b;hp=41333a34b7d10d60d3c7e70e27f294f851a53bd8;hpb=12d37835b4f9c3691460b7386566d39de14b2c4e;p=friendica.git diff --git a/src/Database/PostUpdate.php b/src/Database/PostUpdate.php index 41333a34b7..acc98c882c 100644 --- a/src/Database/PostUpdate.php +++ b/src/Database/PostUpdate.php @@ -1,6 +1,6 @@ get('post_update_version') >= 1506) { + return true; + } + + $id = DI::keyValue()->get('post_update_version_1506_id') ?? 0; + + Logger::info('Start', ['contact' => $id]); + + $start_id = $id; + $rows = 0; + $condition = ["`id` > ? AND `gsid` IS NULL AND `network` = ?", $id, Protocol::DIASPORA]; + $params = ['order' => ['id'], 'limit' => 10000]; + $contacts = DBA::select('contact', ['id', 'url'], $condition, $params); + + if (DBA::errorNo() != 0) { + Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]); + return false; + } + + while ($contact = DBA::fetch($contacts)) { + $id = $contact['id']; + + $parts = parse_url($contact['url']); + unset($parts['path']); + $server = (string)Uri::fromParts($parts); + + DBA::update('contact', + ['gsid' => GServer::getID($server, true), 'baseurl' => GServer::cleanURL($server)], + ['id' => $contact['id']]); + + ++$rows; + } + DBA::close($contacts); + + DI::keyValue()->set('post_update_version_1506_id', $id); + + Logger::info('Processed', ['rows' => $rows, 'last' => $id]); + + if ($start_id == $id) { + DI::keyValue()->set('post_update_version', 1506); + Logger::info('Done'); + return true; + } + + return false; + } + /** * update the "gsid" (global server id) field in the inbox-status table *