Fix PHP 7.2: count(): Parameter must be an array in enchant-based spellchecker (#6234)

pull/6241/head
Aleksander Machniak 7 years ago
parent 08454fb951
commit df3878501c

@ -101,7 +101,7 @@ class rcube_spellchecker_enchant extends rcube_spellchecker_engine
else if (!enchant_dict_check($this->enchant_dictionary, $word)) {
$suggestions = enchant_dict_suggest($this->enchant_dictionary, $word);
if (count($suggestions) > self::MAX_SUGGESTIONS) {
if (is_array($suggestions) && count($suggestions) > self::MAX_SUGGESTIONS) {
$suggestions = array_slice($suggestions, 0, self::MAX_SUGGESTIONS);
}
@ -130,7 +130,7 @@ class rcube_spellchecker_enchant extends rcube_spellchecker_engine
$suggestions = enchant_dict_suggest($this->enchant_dictionary, $word);
if (count($suggestions) > self::MAX_SUGGESTIONS)
if (is_array($suggestions) && count($suggestions) > self::MAX_SUGGESTIONS)
$suggestions = array_slice($suggestions, 0, self::MAX_SUGGESTIONS);
return is_array($suggestions) ? $suggestions : array();

Loading…
Cancel
Save