Don't delete the post when there is some undeleted post-user
This commit is contained in:
parent
bc3a6b2bb7
commit
c6de91a8ec
|
@ -565,6 +565,12 @@ class Post
|
|||
$posts = DBA::select('post-user-view', ['uri-id'], $condition, ['group_by' => ['uri-id']]);
|
||||
while ($rows = DBA::toArray($posts, false, 100)) {
|
||||
$uriids = array_column($rows, 'uri-id');
|
||||
|
||||
// Only delete the "post" entry when all "post-user" entries are deleted
|
||||
if (!empty($update_fields['deleted']) && DBA::exists('post-user', ['uri-id' => $uriids, 'deleted' => false])) {
|
||||
unset($update_fields['deleted']);
|
||||
}
|
||||
|
||||
if (!DBA::update('post', $update_fields, ['uri-id' => $uriids])) {
|
||||
DBA::rollback();
|
||||
Logger::notice('Updating post failed', ['fields' => $update_fields, 'condition' => $condition]);
|
||||
|
|
|
@ -1112,5 +1112,6 @@ function update_1457()
|
|||
function update_1480()
|
||||
{
|
||||
DBA::update('contact', ['next-update' => DBA::NULL_DATETIME], ['network' => Protocol::FEDERATED]);
|
||||
DBA::update('post', ['deleted' => false], ["`uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE NOT `deleted`)"]);
|
||||
return Update::SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue