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'))
|
if (InputHelper::get('submit'))
|
||||||
{
|
{
|
||||||
//remove stuff from auxiliary tables
|
//remove stuff from auxiliary tables
|
||||||
|
foreach ($post->ownComment as $comment)
|
||||||
|
{
|
||||||
|
$comment->post = null;
|
||||||
|
R::store($comment);
|
||||||
|
}
|
||||||
$post->ownFavoritee = [];
|
$post->ownFavoritee = [];
|
||||||
$post->sharedTag = [];
|
$post->sharedTag = [];
|
||||||
R::store($post);
|
R::store($post);
|
||||||
|
|
|
@ -3,7 +3,11 @@ class Model_Comment_QueryBuilder implements AbstractQueryBuilder
|
||||||
{
|
{
|
||||||
public static function build($dbQuery, $query)
|
public static function build($dbQuery, $query)
|
||||||
{
|
{
|
||||||
$dbQuery->from('comment');
|
$dbQuery
|
||||||
$dbQuery->orderBy('id')->desc();
|
->from('comment')
|
||||||
|
->where('post_id')
|
||||||
|
->is()->not('NULL')
|
||||||
|
->orderBy('id')
|
||||||
|
->desc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue