Faster queries, fixed foreign keys

When user is removed, their posts and comments get null user ID now
This commit is contained in:
Marcin Kurczewski
2013-10-19 18:14:19 +02:00
parent 53f9076bff
commit ea463cb0db
6 changed files with 70 additions and 31 deletions

View File

@ -189,6 +189,16 @@ class UserController
if ($suppliedPasswordHash != $user->pass_hash)
throw new SimpleException('Must supply valid password');
}
foreach ($user->alias('commenter')->ownComment as $comment)
{
$comment->commenter = null;
R::store($comment);
}
foreach ($user->alias('uploader')->ownPost as $post)
{
$post->uploader = null;
R::store($post);
}
$user->ownFavoritee = [];
R::store($user);
R::trash($user);
@ -375,6 +385,8 @@ class UserController
->put(($page - 1) * $postsPerPage);
$posts = $searchDbQuery->get();
$posts = R::convertToBeans('post', $posts);
R::preload($posts, ['uploader' => 'user']);
$this->context->transport->user = $user;
$this->context->transport->tab = $tab;
$this->context->transport->paginator = new StdClass;