Fixed dangling postscore and crossref rows

This commit is contained in:
Marcin Kurczewski 2013-11-18 10:26:29 +01:00
parent 7605177a6b
commit 0286e11c30
2 changed files with 3 additions and 0 deletions

View file

@ -552,6 +552,8 @@ class PostController
if (InputHelper::get('submit')) if (InputHelper::get('submit'))
{ {
//remove stuff from auxiliary tables //remove stuff from auxiliary tables
R::trashAll(R::find('postscore', 'post_id = ?', [$post->id]));
R::trashAll(R::find('crossref', 'post_id = ? OR post2_id = ?', [$post->id, $post->id]));
foreach ($post->ownComment as $comment) foreach ($post->ownComment as $comment)
{ {
$comment->post = null; $comment->post = null;

View file

@ -253,6 +253,7 @@ class UserController
if ($suppliedPasswordHash != $user->pass_hash) if ($suppliedPasswordHash != $user->pass_hash)
throw new SimpleException('Must supply valid password'); throw new SimpleException('Must supply valid password');
} }
R::trashAll(R::find('postscore', 'user_id = ?', [$user->id]));
foreach ($user->alias('commenter')->ownComment as $comment) foreach ($user->alias('commenter')->ownComment as $comment)
{ {
$comment->commenter = null; $comment->commenter = null;