aboutsummaryrefslogtreecommitdiff
path: root/mod/search
diff options
context:
space:
mode:
authorBrett Profitt <brett.profitt@gmail.com>2012-12-11 12:57:41 -0800
committerBrett Profitt <brett.profitt@gmail.com>2012-12-11 12:57:41 -0800
commitea2683430f081d8c4463268ca25993e4af4238bf (patch)
tree547dfd9c6a932afadee2e10a46c6410cc146061b /mod/search
parent43a395ae735777bfb5474c4f6a37dc1cd0818a37 (diff)
parent01009d63657b76e2df3e03950975de65e5ee9cf0 (diff)
downloadelgg-ea2683430f081d8c4463268ca25993e4af4238bf.tar.gz
elgg-ea2683430f081d8c4463268ca25993e4af4238bf.tar.bz2
Merge pull request #458 from sembrestels/search-warnings
Avoid some warnings and a division by 0.
Diffstat (limited to 'mod/search')
-rw-r--r--mod/search/start.php4
1 files changed, 3 insertions, 1 deletions
diff --git a/mod/search/start.php b/mod/search/start.php
index d2d7ed3c2..f493508d8 100644
--- a/mod/search/start.php
+++ b/mod/search/start.php
@@ -94,6 +94,8 @@ function search_get_highlighted_relevant_substrings($haystack, $query, $min_matc
if (!$tag_match) {
$words = search_remove_ignored_words($query, 'array');
+ } else {
+ $words = array();
}
// if haystack < $max_length return the entire haystack w/formatting immediately
@@ -142,7 +144,7 @@ function search_get_highlighted_relevant_substrings($haystack, $query, $min_matc
$total_length = array_sum($offsets);
$add_length = 0;
- if ($total_length < $max_length) {
+ if ($total_length < $max_length && $offsets) {
$add_length = floor((($max_length - $total_length) / count($offsets)) / 2);
$starts = array();