mirror of
https://github.com/friendica/friendica
synced 2025-04-25 05:50:12 +00:00
The inbox-status can now be archived for a whole server
This commit is contained in:
parent
7942881f7e
commit
e21db0fe6d
7 changed files with 105 additions and 15 deletions
|
@ -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 = 1484;
|
||||
const VERSION = 1507;
|
||||
|
||||
/**
|
||||
* Calls the post update functions
|
||||
|
@ -117,6 +117,9 @@ class PostUpdate
|
|||
if (!self::update1484()) {
|
||||
return false;
|
||||
}
|
||||
if (!self::update1507()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1184,4 +1187,59 @@ class PostUpdate
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* update the "gsid" (global server id) field in the inbox-status table
|
||||
*
|
||||
* @return bool "true" when the job is done
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
private static function update1507()
|
||||
{
|
||||
// Was the script completed?
|
||||
if (DI::keyValue()->get('post_update_version') >= 1507) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$id = DI::keyValue()->get('post_update_version_1507_id') ?? '';
|
||||
|
||||
Logger::info('Start', ['apcontact' => $id]);
|
||||
|
||||
$start_id = $id;
|
||||
$rows = 0;
|
||||
$condition = ["`url` > ? AND NOT `gsid` IS NULL", $id];
|
||||
$params = ['order' => ['url'], 'limit' => 10000];
|
||||
$apcontacts = DBA::select('apcontact', ['url', 'gsid', 'sharedinbox', 'inbox'], $condition, $params);
|
||||
|
||||
if (DBA::errorNo() != 0) {
|
||||
Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
while ($apcontact = DBA::fetch($apcontacts)) {
|
||||
$id = $apcontact['url'];
|
||||
|
||||
$inbox = [$apcontact['inbox']];
|
||||
if (!empty($apcontact['sharedinbox'])) {
|
||||
$inbox[] = $apcontact['sharedinbox'];
|
||||
}
|
||||
$condition = DBA::mergeConditions(['url' => $inbox], ["`gsid` IS NULL"]);
|
||||
DBA::update('inbox-status', ['gsid' => $apcontact['gsid']], $condition);
|
||||
++$rows;
|
||||
}
|
||||
DBA::close($apcontacts);
|
||||
|
||||
DI::keyValue()->set('post_update_version_1507_id', $id);
|
||||
|
||||
Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
|
||||
|
||||
if ($start_id == $id) {
|
||||
DI::keyValue()->set('post_update_version', 1507);
|
||||
Logger::info('Done');
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue