aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/search
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2008-12-04 16:56:56 +0000
committerNils Adermann <naderman@naderman.de>2008-12-04 16:56:56 +0000
commit945e6e1e78d610fcbf116a2ecf45d47ec4370a97 (patch)
tree0b899e5f54a49600342c03bcf559b3bddd056537 /phpBB/includes/search
parenta41e8c101d3211b915cc065b27f494aa3bb8a741 (diff)
downloadforums-945e6e1e78d610fcbf116a2ecf45d47ec4370a97.tar
forums-945e6e1e78d610fcbf116a2ecf45d47ec4370a97.tar.gz
forums-945e6e1e78d610fcbf116a2ecf45d47ec4370a97.tar.bz2
forums-945e6e1e78d610fcbf116a2ecf45d47ec4370a97.tar.xz
forums-945e6e1e78d610fcbf116a2ecf45d47ec4370a97.zip
Use a left join for the topics table on search to avoid trouble with FROM syntax on some databases (Bug #37005)
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9172 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/search')
-rw-r--r--phpBB/includes/search/fulltext_native.php23
1 files changed, 12 insertions, 11 deletions
diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php
index 0a3fe3754f..b1a035ff43 100644
--- a/phpBB/includes/search/fulltext_native.php
+++ b/phpBB/includes/search/fulltext_native.php
@@ -455,6 +455,7 @@ class fulltext_native extends search_backend
);
$title_match = '';
+ $left_join_topics = false;
$group_by = true;
// Build some display specific sql strings
switch ($fields)
@@ -464,7 +465,7 @@ class fulltext_native extends search_backend
$group_by = false;
// no break
case 'firstpost':
- $sql_array['FROM'][TOPICS_TABLE] = 't';
+ $left_join_topics = true;
$sql_where[] = 'p.post_id = t.topic_first_post_id';
break;
@@ -476,11 +477,7 @@ class fulltext_native extends search_backend
if ($type == 'topics')
{
- if (!isset($sql_array['FROM'][TOPICS_TABLE]))
- {
- $sql_array['FROM'][TOPICS_TABLE] = 't';
- $sql_where[] = 'p.topic_id = t.topic_id';
- }
+ $left_join_topics = true;
$group_by = true;
}
@@ -688,11 +685,7 @@ class fulltext_native extends search_backend
break;
case 't':
- if (!isset($sql_array['FROM'][TOPICS_TABLE]))
- {
- $sql_array['FROM'][TOPICS_TABLE] = 't';
- $sql_where[] = 'p.topic_id = t.topic_id';
- }
+ $left_join_topics = true;
break;
case 'f':
@@ -700,6 +693,14 @@ class fulltext_native extends search_backend
$sql_where[] = 'f.forum_id = p.forum_id';
break;
}
+
+ if ($left_join_topics)
+ {
+ $sql_array['LEFT_JOIN'][$left_join_topics] = array(
+ 'FROM' => TOPICS_TABLE => 't',
+ 'ON' => 'p.topic_id = t.topic_id'
+ );
+ }
$sql_array['WHERE'] = implode(' AND ', $sql_where);
$sql_array['GROUP_BY'] = ($group_by) ? (($type == 'posts') ? 'p.post_id' : 'p.topic_id') . ', ' . $sort_by_sql[$sort_key] : '';