[COMPONENT][Link] Wrap delete operations in transactions

This commit is contained in:
Diogo Peralta Cordeiro 2021-12-28 06:16:32 +00:00
parent 46d121ef7b
commit 5c2b46a71d
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
1 changed files with 3 additions and 2 deletions

View File

@ -26,6 +26,7 @@ namespace Component\Link;
use App\Core\DB\DB; use App\Core\DB\DB;
use App\Core\Event; use App\Core\Event;
use App\Core\Modules\Component; use App\Core\Modules\Component;
use App\Entity\Actor;
use App\Entity\Note; use App\Entity\Note;
use App\Util\Common; use App\Util\Common;
use App\Util\HTML; use App\Util\HTML;
@ -260,9 +261,9 @@ class Link extends Component
return HTML::html(['a' => ['attrs' => $attrs, $url]], options: ['indent' => false]); return HTML::html(['a' => ['attrs' => $attrs, $url]], options: ['indent' => false]);
} }
public function onNoteDeleteRelated(Note &$note): bool public function onNoteDeleteRelated(Note &$note, Actor $actor): bool
{ {
NoteToLink::removeWhereNoteId($note->getId()); DB::wrapInTransaction(fn () => NoteToLink::removeWhereNoteId($note->getId()));
return Event::next; return Event::next;
} }
} }