Line 232 | Line 232 |
---|
}
// Filter out as above
|
}
// Filter out as above
|
$split_keywords = preg_replace("#[\n\r\t]+#", ' ', trim(htmlspecialchars_decode($keywords)));
| $split_keywords = preg_replace("#[\n\r\t]+#", ' ', trim(html_entity_decode($keywords, ENT_COMPAT)));
|
// Split words $split_keywords = preg_replace('#([^\p{L}\p{N}\'*"()])#u', '$1$1', str_replace('\'\'', '\' \'', trim($split_keywords)));
| // Split words $split_keywords = preg_replace('#([^\p{L}\p{N}\'*"()])#u', '$1$1', str_replace('\'\'', '\' \'', trim($split_keywords)));
|
Line 568 | Line 568 |
---|
); extract($this->phpbb_dispatcher->trigger_event('core.search_mysql_keywords_main_query_before', compact($vars)));
|
); extract($this->phpbb_dispatcher->trigger_event('core.search_mysql_keywords_main_query_before', compact($vars)));
|
$sql_select = (!$result_count) ? 'SQL_CALC_FOUND_ROWS ' : ''; $sql_select = ($type == 'posts') ? $sql_select . 'p.post_id' : 'DISTINCT ' . $sql_select . 't.topic_id';
| $sql_select = ($type == 'posts') ? 'DISTINCT p.post_id' : 'DISTINCT t.topic_id'; $sql_select .= $sort_by_sql[$sort_key] ? ", {$sort_by_sql[$sort_key]}" : '';
|
$sql_from = ($join_topic) ? TOPICS_TABLE . ' t, ' : ''; $field = ($type == 'posts') ? 'post_id' : 'topic_id'; if (count($author_ary) && $author_name)
| $sql_from = ($join_topic) ? TOPICS_TABLE . ' t, ' : ''; $field = ($type == 'posts') ? 'post_id' : 'topic_id'; if (count($author_ary) && $author_name)
|
Line 597 | Line 597 |
---|
$sql = "SELECT $sql_select FROM $sql_from$sql_sort_table" . POSTS_TABLE . " p
|
$sql = "SELECT $sql_select FROM $sql_from$sql_sort_table" . POSTS_TABLE . " p
|
WHERE MATCH ($sql_match) AGAINST ('" . $this->db->sql_escape(htmlspecialchars_decode($this->search_query)) . "' IN BOOLEAN MODE)
| WHERE MATCH ($sql_match) AGAINST ('" . $this->db->sql_escape(html_entity_decode($this->search_query, ENT_COMPAT)) . "' IN BOOLEAN MODE)
|
$sql_where_options ORDER BY $sql_sort"; $this->db->sql_return_on_error(true);
| $sql_where_options ORDER BY $sql_sort"; $this->db->sql_return_on_error(true);
|
Line 610 | Line 610 |
---|
$this->db->sql_freeresult($result);
$id_ary = array_unique($id_ary);
|
$this->db->sql_freeresult($result);
$id_ary = array_unique($id_ary);
|
| |
// if the total result count is not cached yet, retrieve it from the db if (!$result_count && count($id_ary)) {
|
// if the total result count is not cached yet, retrieve it from the db if (!$result_count && count($id_ary)) {
|
$sql_found_rows = 'SELECT FOUND_ROWS() as result_count';
| $sql_found_rows = str_replace("SELECT $sql_select", "SELECT COUNT($sql_select) as result_count", $sql);
|
$result = $this->db->sql_query($sql_found_rows); $result_count = (int) $this->db->sql_fetchfield('result_count'); $this->db->sql_freeresult($result);
| $result = $this->db->sql_query($sql_found_rows); $result_count = (int) $this->db->sql_fetchfield('result_count'); $this->db->sql_freeresult($result);
|
Line 828 | Line 827 |
---|
extract($this->phpbb_dispatcher->trigger_event('core.search_mysql_author_query_before', compact($vars)));
// If the cache was completely empty count the results
|
extract($this->phpbb_dispatcher->trigger_event('core.search_mysql_author_query_before', compact($vars)));
// If the cache was completely empty count the results
|
$calc_results = ($result_count) ? '' : 'SQL_CALC_FOUND_ROWS ';
| $sql_select = ($type == 'posts') ? 'p.post_id' : 't.topic_id'; $sql_select .= $sort_by_sql[$sort_key] ? ", {$sort_by_sql[$sort_key]}" : '';
|
// Build the query for really selecting the post_ids if ($type == 'posts') {
|
// Build the query for really selecting the post_ids if ($type == 'posts') {
|
$sql = "SELECT {$calc_results}p.post_id
| $sql = "SELECT $sql_select
|
FROM " . $sql_sort_table . POSTS_TABLE . ' p' . (($firstpost_only) ? ', ' . TOPICS_TABLE . ' t ' : ' ') . " WHERE $sql_author $sql_topic_id
| FROM " . $sql_sort_table . POSTS_TABLE . ' p' . (($firstpost_only) ? ', ' . TOPICS_TABLE . ' t ' : ' ') . " WHERE $sql_author $sql_topic_id
|
Line 847 | Line 847 |
---|
} else {
|
} else {
|
$sql = "SELECT {$calc_results}t.topic_id
| $sql = "SELECT $sql_select
|
FROM " . $sql_sort_table . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p WHERE $sql_author $sql_topic_id
| FROM " . $sql_sort_table . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p WHERE $sql_author $sql_topic_id
|
Line 857 | Line 857 |
---|
AND t.topic_id = p.topic_id $sql_sort_join $sql_time
|
AND t.topic_id = p.topic_id $sql_sort_join $sql_time
|
GROUP BY t.topic_id
| GROUP BY $sql_select
|
ORDER BY $sql_sort"; $field = 'topic_id'; }
| ORDER BY $sql_sort"; $field = 'topic_id'; }
|
Line 874 | Line 874 |
---|
// retrieve the total result count if needed if (!$result_count) {
|
// retrieve the total result count if needed if (!$result_count) {
|
$sql_found_rows = 'SELECT FOUND_ROWS() as result_count';
| $sql_found_rows = str_replace("SELECT $sql_select", "SELECT COUNT(*) as result_count", $sql);
|
$result = $this->db->sql_query($sql_found_rows);
|
$result = $this->db->sql_query($sql_found_rows);
|
$result_count = (int) $this->db->sql_fetchfield('result_count');
| $result_count = ($type == 'posts') ? (int) $this->db->sql_fetchfield('result_count') : count($this->db->sql_fetchrowset($result));
|
$this->db->sql_freeresult($result);
if (!$result_count)
| $this->db->sql_freeresult($result);
if (!$result_count)
|