Fixes several database errors, removes "relation" handling

This commit is contained in:
Michael 2021-02-25 05:13:49 +00:00
parent de90f5351f
commit 99a145f7cf
11 changed files with 39 additions and 176 deletions

View file

@ -137,14 +137,16 @@ class Relation
$actor = Contact::getIdForURL($contact);
if (!empty($actor)) {
if (in_array($contact, $followers)) {
$fields = ['cid' => $target, 'relation-cid' => $actor, 'follows' => true, 'follow-updated' => DateTimeFormat::utcNow()];
DBA::insert('contact-relation', $fields, Database::INSERT_UPDATE);
$condition = ['cid' => $target, 'relation-cid' => $actor];
DBA::insert('contact-relation', $condition, Database::INSERT_IGNORE);
DBA::update('contact-relation', ['follows' => true, 'follow-updated' => DateTimeFormat::utcNow()], $condition);
$follower_counter++;
}
if (in_array($contact, $followings)) {
$fields = ['cid' => $actor, 'relation-cid' => $target, 'follows' => true, 'follow-updated' => DateTimeFormat::utcNow()];
DBA::insert('contact-relation', $fields, Database::INSERT_UPDATE);
$condition = ['cid' => $actor, 'relation-cid' => $target];
DBA::insert('contact-relation', $condition, Database::INSERT_IGNORE);
DBA::update('contact-relation', ['follows' => true, 'follow-updated' => DateTimeFormat::utcNow()], $condition);
$following_counter++;
}
}

View file

@ -242,7 +242,7 @@ class Event
return;
}
DBA::delete('event', ['id' => $event_id], ['cascade' => false]);
DBA::delete('event', ['id' => $event_id]);
Logger::log("Deleted event ".$event_id, Logger::DEBUG);
}

View file

@ -318,14 +318,6 @@ class Item
Post\DeliveryData::delete($item['uri-id']);
// When the permission set will be used in photo and events as well,
// this query here needs to be extended.
// @todo Currently deactivated. We need the permission set in the deletion process.
// This is a reminder to add the removal somewhere else.
//if (!empty($item['psid']) && !self::exists(['psid' => $item['psid'], 'deleted' => false])) {
// DBA::delete('permissionset', ['id' => $item['psid']], ['cascade' => false]);
//}
// If it's the parent of a comment thread, kill all the kids
if ($item['gravity'] == GRAVITY_PARENT) {
self::markForDeletion(['parent' => $item['parent'], 'deleted' => false], $priority);