aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2008-09-16 12:36:28 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2008-09-16 12:36:28 +0000
commit8dd2c17bf94b33d3629e96679a07bc6908caff38 (patch)
tree7f002a5732c764b6a79cad2d352b441185d853e3 /phpBB
parentda402759abce838f891961a296ab719e5a5516a9 (diff)
downloadforums-8dd2c17bf94b33d3629e96679a07bc6908caff38.tar
forums-8dd2c17bf94b33d3629e96679a07bc6908caff38.tar.gz
forums-8dd2c17bf94b33d3629e96679a07bc6908caff38.tar.bz2
forums-8dd2c17bf94b33d3629e96679a07bc6908caff38.tar.xz
forums-8dd2c17bf94b33d3629e96679a07bc6908caff38.zip
Fix Wrong table order in query obtaining posts if post id given. In MSSQL there is an sql error due to this bug.
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8851 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/docs/CHANGELOG.html1
-rw-r--r--phpBB/viewtopic.php15
2 files changed, 11 insertions, 5 deletions
diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html
index 61b4caf1b0..b06334bd9a 100644
--- a/phpBB/docs/CHANGELOG.html
+++ b/phpBB/docs/CHANGELOG.html
@@ -123,6 +123,7 @@
<li>[Fix] Language typos/fixes. (Bug #27625, #30755)</li>
<li>[Fix] Added missing terms parameter to search pagination. (Bug #34085)</li>
<li>[Change] Do not use the topics posted table when performing an egosearch.</li>
+ <li>[Fix] Wrong table order in query obtaining posts if post id given.</li>
</ul>
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index 8db6ed1ebd..fac6476a55 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -178,12 +178,18 @@ if ($view && !$post_id)
$sql_array = array(
'SELECT' => 't.*, f.*',
- 'FROM' => array(
- FORUMS_TABLE => 'f',
- TOPICS_TABLE => 't',
- )
+ 'FROM' => array(FORUMS_TABLE => 'f'),
);
+// The FROM-Order is quite important here, else t.* columns can not be correctly bound.
+if ($post_id)
+{
+ $sql_array['FROM'][POSTS_TABLE] = 'p';
+}
+
+// Topics table need to be the last in the chain
+$sql_array['FROM'][TOPICS_TABLE] = 't';
+
if ($user->data['is_registered'])
{
$sql_array['SELECT'] .= ', tw.notify_status';
@@ -226,7 +232,6 @@ if (!$post_id)
else
{
$sql_array['WHERE'] = "p.post_id = $post_id AND t.topic_id = p.topic_id" . ((!$auth->acl_get('m_approve', $forum_id)) ? ' AND p.post_approved = 1' : '');
- $sql_array['FROM'][POSTS_TABLE] = 'p';
}
$sql_array['WHERE'] .= ' AND (f.forum_id = t.forum_id';