1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-11 01:55:24 +02:00

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
This commit is contained in:
Nils Adermann 2008-12-04 16:56:56 +00:00
parent a41e8c101d
commit 945e6e1e78
2 changed files with 13 additions and 11 deletions

View File

@ -111,6 +111,7 @@
<li>[Feature] Added 'AGO' setting to relative date strings. For example: posted 14 minutes ago. (Patch by BartVB)</li>
<li>[Sec] Fixed an issue where deactivated accounts could be re-activated without the required privileges. (Reported by Jorick)</li>
<li>[Sec] Ask for forum password if post within passworded forum quoted in private message. (Reported by nickvergessen)</li>
<li>[Fix] Use a left join for the topics table on search to avoid trouble with FROM syntax on some databases (Bug #37005)</li>
</ul>
<a name="v302"></a><h3>1.ii. Changes since 3.0.2</h3>

View File

@ -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] : '';