X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FDatabase%2FPostUpdate.php;h=6d744a1ba1a26e1db2102fad690af49bc96212e9;hb=61e023d4482ef3a6366b1b0cef0ab7dbd4fdf30a;hp=0b640f187562ef647ec8d1b3419eb2baab4fdfe5;hpb=b46b88cc109e3ac09772a0ebce0c900eaf09dc01;p=friendica.git diff --git a/src/Database/PostUpdate.php b/src/Database/PostUpdate.php index 0b640f1875..6d744a1ba1 100644 --- a/src/Database/PostUpdate.php +++ b/src/Database/PostUpdate.php @@ -1,6 +1,6 @@ get('system', 'post_update_version') >= 1452) { + return true; + } + + $id = DI::config()->get('system', 'post_update_version_1452_id', 0); + + Logger::info('Start', ['uri-id' => $id]); + + $rows = 0; + $received = ''; + + $conversations = DBA::p("SELECT `post-view`.`uri-id`, `conversation`.`source`, `conversation`.`received` FROM `conversation` + INNER JOIN `post-view` ON `post-view`.`uri` = `conversation`.`item-uri` + WHERE NOT `source` IS NULL AND `conversation`.`protocol` = ? AND `uri-id` > ? LIMIT ?", + Conversation::PARCEL_ACTIVITYPUB, $id, 1000); + + if (DBA::errorNo() != 0) { + Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]); + return false; + } + + while ($conversation = DBA::fetch($conversations)) { + $id = $conversation['uri-id']; + $received = $conversation['received']; + + $raw = json_decode($conversation['source'], true); + if (empty($raw)) { + continue; + } + $activity = JsonLD::compact($raw); + + $urls = Receiver::getReceiverURL($activity); + Processor::storeReceivers($conversation['uri-id'], $urls); + + if (!empty($activity['as:object'])) { + $urls = array_merge($urls, Receiver::getReceiverURL($activity['as:object'])); + Processor::storeReceivers($conversation['uri-id'], $urls); + } + ++$rows; + } + + DBA::close($conversations); + + DI::config()->set('system', 'post_update_version_1452_id', $id); + + Logger::info('Processed', ['rows' => $rows, 'last' => $id, 'last-received' => $received]); + + if ($rows <= 100) { + DI::config()->set('system', 'post_update_version', 1452); + Logger::info('Done'); + return true; + } + + return false; + } }