diff options
| author | Michael Save <savetheinternet@tinyboard.org> | 2012-09-28 04:50:25 +1000 |
|---|---|---|
| committer | Michael Save <savetheinternet@tinyboard.org> | 2012-09-28 04:50:25 +1000 |
| commit | 696c1a05b72f9c5ea7ae0aa15add3c0eb6bc6ce5 (patch) | |
| tree | 1df00d7522b3a6e4e97448aa2f062a7aec3b6e25 | |
| parent | 6b7daacdb39605d249333788c95e7ece88470c99 (diff) | |
Quick fix relating to last commit
| -rw-r--r-- | inc/functions.php | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/inc/functions.php b/inc/functions.php index 9f20180e..17eb9bee 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -973,8 +973,9 @@ function index($page, $mod=false) { $th['sticky'], $th['locked'], $th['sage'], $th['embed'], $mod ? '?/' : $config['root'], $mod ); - if (!$mod && $config['cache']['enabled'] && $cached_replies = cache::get("thread_index_{$board['uri']}_{$th['id']}")) { - $thread->posts = json_decode($cached_replies); + if (!$mod && $config['cache']['enabled'] && $cached_stuff = cache::get("thread_index_{$board['uri']}_{$th['id']}")) { + $post_count = $cached_stuff[0]; + $thread->posts = json_decode($cached_stuff[1]); } else { $posts = prepare(sprintf("SELECT * FROM `posts_%s` WHERE `thread` = :id ORDER BY `id` DESC LIMIT :limit", $board['uri'])); $posts->bindValue(':id', $th['id']); @@ -992,9 +993,11 @@ function index($page, $mod=false) { $po['filename'], $po['ip'], $po['embed'], $mod ? '?/' : $config['root'], $mod) ); } + + $post_count = $posts->rowCount(); } - if ($posts->rowCount() == ($th['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview'])) { + if ($post_count == ($th['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview'])) { $count = prepare(sprintf("SELECT COUNT(`id`) as `num` FROM `posts_%s` WHERE `thread` = :thread UNION ALL SELECT COUNT(`id`) FROM `posts_%s` WHERE `file` IS NOT NULL AND `thread` = :thread", $board['uri'], $board['uri'])); $count->bindValue(':thread', $th['id'], PDO::PARAM_INT); $count->execute() or error(db_error($count)); @@ -1007,7 +1010,7 @@ function index($page, $mod=false) { } if ($config['cache']['enabled']) - cache::set("thread_index_{$board['uri']}_{$th['id']}", json_encode($thread->posts)); + cache::set("thread_index_{$board['uri']}_{$th['id']}", json_encode(array($posts->rowCount(), $thread->posts))); $thread->posts = array_reverse($thread->posts); |
