diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2008-09-16 12:37:33 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2008-09-16 12:37:33 +0000 |
commit | ca07af715ff64da81f7403abf6404ee6feefaa3c (patch) | |
tree | 5180082bec8e1c075314c2ef606fa489a971b012 | |
parent | 46b4d09e3a4c88f2bbba5ef6db21ab2977e45ffa (diff) | |
download | forums-ca07af715ff64da81f7403abf6404ee6feefaa3c.tar forums-ca07af715ff64da81f7403abf6404ee6feefaa3c.tar.gz forums-ca07af715ff64da81f7403abf6404ee6feefaa3c.tar.bz2 forums-ca07af715ff64da81f7403abf6404ee6feefaa3c.tar.xz forums-ca07af715ff64da81f7403abf6404ee6feefaa3c.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/trunk@8852 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r-- | phpBB/viewtopic.php | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index c1fb3f2931..b7cf6b85e5 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'; |