]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Avoid some warnings and a division by 0.
authorSem <sembrestels@riseup.net>
Wed, 5 Dec 2012 00:51:03 +0000 (01:51 +0100)
committerSem <sembrestels@riseup.net>
Wed, 5 Dec 2012 00:51:03 +0000 (01:51 +0100)
mod/search/start.php

index d2d7ed3c22982b1c1d8134998d57a17e9b3cc3ba..f493508d819a05314a7b4c6418099cd8ca4cd9a5 100644 (file)
@@ -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();