Fixed post deletion
When post was deleted foreign keys in corresponding comments weren't NULLified.
This commit is contained in:
parent
19eea1e5b6
commit
157572d9ca
2 changed files with 11 additions and 2 deletions
|
@ -457,6 +457,11 @@ class PostController
|
|||
if (InputHelper::get('submit'))
|
||||
{
|
||||
//remove stuff from auxiliary tables
|
||||
foreach ($post->ownComment as $comment)
|
||||
{
|
||||
$comment->post = null;
|
||||
R::store($comment);
|
||||
}
|
||||
$post->ownFavoritee = [];
|
||||
$post->sharedTag = [];
|
||||
R::store($post);
|
||||
|
|
|
@ -3,7 +3,11 @@ class Model_Comment_QueryBuilder implements AbstractQueryBuilder
|
|||
{
|
||||
public static function build($dbQuery, $query)
|
||||
{
|
||||
$dbQuery->from('comment');
|
||||
$dbQuery->orderBy('id')->desc();
|
||||
$dbQuery
|
||||
->from('comment')
|
||||
->where('post_id')
|
||||
->is()->not('NULL')
|
||||
->orderBy('id')
|
||||
->desc();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue