From 77e00d14a196d14910bdf2275ab01380b7b7f18f Mon Sep 17 00:00:00 2001 From: rxu Date: Sat, 26 Nov 2011 01:30:03 +0800 Subject: [PATCH] [ticket/10497] Fix SQL error when guest visits forum with unread topic Regression from the ticket PHPBB3-9008 fix. When topic marking was enabled for guests, and a guest visited a forum with a new topic which is marked unread, the built SQL missed an alias for a TOPICS_TABLE which resulted in the following error: Unknown column 't.topic_approved' in 'where clause' [1054] The fix is to add an alias for the table. PHPBB3-10497 PHPBB3-9008 --- phpBB/includes/functions.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 944e53052b..7ce83b871a 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1943,11 +1943,11 @@ function update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_ti } else { - $sql = 'SELECT topic_id - FROM ' . TOPICS_TABLE . ' - WHERE forum_id = ' . $forum_id . ' - AND topic_last_post_time > ' . $mark_time_forum . ' - AND topic_moved_id = 0 ' . + $sql = 'SELECT t.topic_id + FROM ' . TOPICS_TABLE . ' t + WHERE t.forum_id = ' . $forum_id . ' + AND t.topic_last_post_time > ' . $mark_time_forum . ' + AND t.topic_moved_id = 0 ' . $sql_update_unapproved; $result = $db->sql_query($sql);