aboutsummaryrefslogtreecommitdiff
path: root/mod/search/start.php
diff options
context:
space:
mode:
authorSem <sembrestels@riseup.net>2012-12-05 01:51:03 +0100
committerSem <sembrestels@riseup.net>2012-12-05 01:51:03 +0100
commit01009d63657b76e2df3e03950975de65e5ee9cf0 (patch)
tree9f658195a3b63337d8ccdf596d317068a45957d1 /mod/search/start.php
parentb2232139f13b759e8f5ce62def75eaeaa530a5b6 (diff)
downloadelgg-01009d63657b76e2df3e03950975de65e5ee9cf0.tar.gz
elgg-01009d63657b76e2df3e03950975de65e5ee9cf0.tar.bz2
Avoid some warnings and a division by 0.
Diffstat (limited to 'mod/search/start.php')
-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();