From 0286e11c3006a7b6e09986ac00161f07745ead70 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Mon, 18 Nov 2013 10:26:29 +0100 Subject: [PATCH] Fixed dangling postscore and crossref rows --- src/Controllers/PostController.php | 2 ++ src/Controllers/UserController.php | 1 + 2 files changed, 3 insertions(+) diff --git a/src/Controllers/PostController.php b/src/Controllers/PostController.php index 17277043..bfadf93b 100644 --- a/src/Controllers/PostController.php +++ b/src/Controllers/PostController.php @@ -552,6 +552,8 @@ class PostController if (InputHelper::get('submit')) { //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) { $comment->post = null; diff --git a/src/Controllers/UserController.php b/src/Controllers/UserController.php index 32914b11..1ab75592 100644 --- a/src/Controllers/UserController.php +++ b/src/Controllers/UserController.php @@ -253,6 +253,7 @@ class UserController if ($suppliedPasswordHash != $user->pass_hash) throw new SimpleException('Must supply valid password'); } + R::trashAll(R::find('postscore', 'user_id = ?', [$user->id])); foreach ($user->alias('commenter')->ownComment as $comment) { $comment->commenter = null;