From 7402328b8177a2080cc269be12aeb84f54d65a22 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Thu, 16 Aug 2012 22:35:50 +0530 Subject: [ticket/11051] function instead of accessing property in search Use get_search_query() instead of accessing the search_query property directly as it is now protected. PHPBB3-11051 --- phpBB/search.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/search.php') diff --git a/phpBB/search.php b/phpBB/search.php index 190da5247f..c6c92e68b0 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -291,7 +291,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) if ($keywords) { $correct_query = $search->split_keywords($keywords, $search_terms); - if (!$correct_query || (empty($search->search_query) && !sizeof($author_id_ary) && !$search_id)) + if (!$correct_query || (!$search->get_search_query() && !sizeof($author_id_ary) && !$search_id)) { $ignored = (sizeof($search->common_words)) ? sprintf($user->lang['IGNORED_TERMS_EXPLAIN'], implode(' ', $search->common_words)) . '
' : ''; trigger_error($ignored . $user->lang('NO_KEYWORDS', $user->lang('CHARACTERS', (int) $search->word_length['min']), $user->lang('CHARACTERS', (int) $search->word_length['max']))); @@ -526,7 +526,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) sort($m_approve_fid_ary); sort($author_id_ary); - if (!empty($search->search_query)) + if ($search->get_search_query()) { $total_match_count = $search->keyword_search($show_results, $search_fields, $search_terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page); } @@ -609,7 +609,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) 'SEARCH_TITLE' => $l_search_title, 'SEARCH_MATCHES' => $l_search_matches, 'SEARCH_WORDS' => $keywords, - 'SEARCHED_QUERY' => $search->search_query, + 'SEARCHED_QUERY' => $search->get_search_query(), 'IGNORED_WORDS' => (sizeof($search->common_words)) ? implode(' ', $search->common_words) : '', 'PAGE_NUMBER' => phpbb_on_page($template, $user, $u_search, $total_match_count, $per_page, $start), -- cgit v1.2.1 From 9b9dc2fab71ec95c4dc48787dd9950872773cfa7 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Thu, 16 Aug 2012 23:16:26 +0530 Subject: [ticket/11051] use get_common_words in search backend Use get_common_words() instead of accessing the common_words property directly as it is now protected. PHPBB3-11051 --- phpBB/search.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/search.php') diff --git a/phpBB/search.php b/phpBB/search.php index c6c92e68b0..fd67b483e8 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -293,7 +293,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) $correct_query = $search->split_keywords($keywords, $search_terms); if (!$correct_query || (!$search->get_search_query() && !sizeof($author_id_ary) && !$search_id)) { - $ignored = (sizeof($search->common_words)) ? sprintf($user->lang['IGNORED_TERMS_EXPLAIN'], implode(' ', $search->common_words)) . '
' : ''; + $ignored = (sizeof($search->get_common_words())) ? sprintf($user->lang['IGNORED_TERMS_EXPLAIN'], implode(' ', $search->get_common_words())) . '
' : ''; trigger_error($ignored . $user->lang('NO_KEYWORDS', $user->lang('CHARACTERS', (int) $search->word_length['min']), $user->lang('CHARACTERS', (int) $search->word_length['max']))); } } @@ -610,7 +610,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) 'SEARCH_MATCHES' => $l_search_matches, 'SEARCH_WORDS' => $keywords, 'SEARCHED_QUERY' => $search->get_search_query(), - 'IGNORED_WORDS' => (sizeof($search->common_words)) ? implode(' ', $search->common_words) : '', + 'IGNORED_WORDS' => (sizeof($search->get_common_words())) ? implode(' ', $search->get_common_words()) : '', 'PAGE_NUMBER' => phpbb_on_page($template, $user, $u_search, $total_match_count, $per_page, $start), 'PHRASE_SEARCH_DISABLED' => $phrase_search_disabled, -- cgit v1.2.1 From a2e1989b012e3f77a18c2758cd913245ce3c180b Mon Sep 17 00:00:00 2001 From: Dhruv Date: Fri, 17 Aug 2012 00:11:32 +0530 Subject: [ticket/11051] use get_word_length in search backend Use get_word_length() instead od accessing the word_length property directly as it is now protected. PHPBB3-11051 --- phpBB/search.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'phpBB/search.php') diff --git a/phpBB/search.php b/phpBB/search.php index fd67b483e8..54f0f225a0 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -294,7 +294,9 @@ if ($keywords || $author || $author_id || $search_id || $submit) if (!$correct_query || (!$search->get_search_query() && !sizeof($author_id_ary) && !$search_id)) { $ignored = (sizeof($search->get_common_words())) ? sprintf($user->lang['IGNORED_TERMS_EXPLAIN'], implode(' ', $search->get_common_words())) . '
' : ''; - trigger_error($ignored . $user->lang('NO_KEYWORDS', $user->lang('CHARACTERS', (int) $search->word_length['min']), $user->lang('CHARACTERS', (int) $search->word_length['max']))); + // Function cannot be directly used as associative array for php < 5.4 + $word_length = $search->get_word_length(); + trigger_error($ignored . $user->lang('NO_KEYWORDS', $user->lang('CHARACTERS', (int) $word_length['min']), $user->lang('CHARACTERS', (int) $word_length['max']))); } } -- cgit v1.2.1 From 52b25aaf20f512911a981958e0efa9365eb34489 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Thu, 4 Oct 2012 01:51:57 +0530 Subject: [ticket/11051] add get_word_len() in sphinx search get_word_len() for sphinx search backend returns false always and triggers proper error. PHPBB3-11051 --- phpBB/search.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'phpBB/search.php') diff --git a/phpBB/search.php b/phpBB/search.php index 54f0f225a0..e869c8eebd 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -296,7 +296,14 @@ if ($keywords || $author || $author_id || $search_id || $submit) $ignored = (sizeof($search->get_common_words())) ? sprintf($user->lang['IGNORED_TERMS_EXPLAIN'], implode(' ', $search->get_common_words())) . '
' : ''; // Function cannot be directly used as associative array for php < 5.4 $word_length = $search->get_word_length(); - trigger_error($ignored . $user->lang('NO_KEYWORDS', $user->lang('CHARACTERS', (int) $word_length['min']), $user->lang('CHARACTERS', (int) $word_length['max']))); + if ($word_length) + { + trigger_error($ignored . $user->lang('NO_KEYWORDS', $user->lang('CHARACTERS', (int) $word_length['min']), $user->lang('CHARACTERS', (int) $word_length['max']))); + } + else + { + trigger_error($ignored); + } } } -- cgit v1.2.1 From 67939192ae287b958902b382c6dd344c2cb74a74 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Thu, 4 Oct 2012 23:17:18 +0530 Subject: [ticket/11051] remove unnecessary comment PHPBB3-11051 --- phpBB/search.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/search.php') diff --git a/phpBB/search.php b/phpBB/search.php index e869c8eebd..f392e386c7 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -294,7 +294,6 @@ if ($keywords || $author || $author_id || $search_id || $submit) if (!$correct_query || (!$search->get_search_query() && !sizeof($author_id_ary) && !$search_id)) { $ignored = (sizeof($search->get_common_words())) ? sprintf($user->lang['IGNORED_TERMS_EXPLAIN'], implode(' ', $search->get_common_words())) . '
' : ''; - // Function cannot be directly used as associative array for php < 5.4 $word_length = $search->get_word_length(); if ($word_length) { -- cgit v1.2.1 From be884b7e290edfaf5db189e6c3cf22024906f159 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Thu, 4 Oct 2012 23:32:50 +0530 Subject: [ticket/11051] add common_words variable PHPBB3-11051 --- phpBB/search.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'phpBB/search.php') diff --git a/phpBB/search.php b/phpBB/search.php index f392e386c7..7eda3c4d1d 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -287,13 +287,15 @@ if ($keywords || $author || $author_id || $search_id || $submit) trigger_error($error); } + $common_words = $search->get_common_words(); + // let the search module split up the keywords if ($keywords) { $correct_query = $search->split_keywords($keywords, $search_terms); if (!$correct_query || (!$search->get_search_query() && !sizeof($author_id_ary) && !$search_id)) { - $ignored = (sizeof($search->get_common_words())) ? sprintf($user->lang['IGNORED_TERMS_EXPLAIN'], implode(' ', $search->get_common_words())) . '
' : ''; + $ignored = (sizeof($common_words)) ? sprintf($user->lang['IGNORED_TERMS_EXPLAIN'], implode(' ', $common_words)) . '
' : ''; $word_length = $search->get_word_length(); if ($word_length) { @@ -618,7 +620,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) 'SEARCH_MATCHES' => $l_search_matches, 'SEARCH_WORDS' => $keywords, 'SEARCHED_QUERY' => $search->get_search_query(), - 'IGNORED_WORDS' => (sizeof($search->get_common_words())) ? implode(' ', $search->get_common_words()) : '', + 'IGNORED_WORDS' => (sizeof($common_words)) ? implode(' ', $common_words) : '', 'PAGE_NUMBER' => phpbb_on_page($template, $user, $u_search, $total_match_count, $per_page, $start), 'PHRASE_SEARCH_DISABLED' => $phrase_search_disabled, -- cgit v1.2.1