CoolCMS API

OwnedThreadDeleteTrait

Deletes the comment and rating threads of hard-deleted records.

A thread is created per record (afterSave(), CommentThreadCreatorTrait, RatingThreadCreatorTrait) and the record FK to it is SET NULL on the record side, so a delete without this left the thread orphaned (a deleted user kept its profile rating thread).

Call it inside the delete transaction, after the owner rows are gone (typically from the manager afterDelete(), DeleteTrait): a failure then rolls the whole delete back, and the managed owner no longer references the thread when the thread manager flushes. A thread already gone is skipped, so the delete of the owner never fails on it. Comments, ratings and votes go with the thread by DB cascade.

Table of Contents

Methods

deleteOwnedThreads()  : Result|null
ownedThreadIds()  : array{comment: list, rating: list}
Reads the thread ids from the entities preloaded before the delete (`getCommentThreadId()` / `getRatingThreadId()`).

Methods

deleteOwnedThreads()

protected deleteOwnedThreads(array<int, int> $commentThreadIds, array<int, int> $ratingThreadIds, CommentThreadManager|null $commentThreadManager, RatingThreadManager|null $ratingThreadManager) : Result|null
Parameters
$commentThreadIds : array<int, int>
$ratingThreadIds : array<int, int>
$commentThreadManager : CommentThreadManager|null
$ratingThreadManager : RatingThreadManager|null
Return values
Result|null —

a failed Result rolls the delete back; null = done

ownedThreadIds()

Reads the thread ids from the entities preloaded before the delete (`getCommentThreadId()` / `getRatingThreadId()`).

protected static ownedThreadIds(array<string|int, object> $entities) : array{comment: list, rating: list}
Parameters
$entities : array<string|int, object>
Return values
array{comment: list, rating: list}
On this page

Search results