mirror of
https://github.com/friendica/friendica
synced 2025-04-24 02:30:13 +00:00
Don't delete the post when there is some undeleted post-user
This commit is contained in:
parent
bc3a6b2bb7
commit
c6de91a8ec
2 changed files with 7 additions and 0 deletions
|
@ -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]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue