aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/functions_posting.php13
1 files changed, 8 insertions, 5 deletions
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index 7aba451285..8e3851e86c 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -97,14 +97,17 @@ function update_last_post_information($type, $id)
$update_sql = array();
- $sql = 'SELECT MAX(post_id) as last_post_id
- FROM ' . POSTS_TABLE . "
- WHERE post_approved = 1
- AND {$type}_id = $id";
+ $sql = 'SELECT MAX(p.post_id) as last_post_id
+ FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t
+ WHERE p.topic_id = t.topic_id
+ AND p.post_approved = 1
+ AND t.topic_approved = 1
+ AND p.{$type}_id = $id";
+
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
- if ($row['last_post_id'])
+ if ((int) $row['last_post_id'])
{
$sql = 'SELECT p.post_id, p.poster_id, p.post_time, u.username, p.post_username
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u