Handle missing php-pspell gracefully, and log to debug.log.

This commit is contained in:
Retro_Guy 2024-12-17 07:22:02 -07:00
parent 83c551ae82
commit 17d1fc0cad
1 changed files with 8 additions and 3 deletions

View File

@ -552,7 +552,12 @@ function display_search_tools($home = true)
function get_suggestion($word) function get_suggestion($word)
{ {
global $OVERRIDES, $logfile; global $OVERRIDES, $logfile, $debug_log;
if (!function_exists('pspell_new')) {
file_put_contents($debug_log, "\n" . logging_prefix() . " PSPELL Missing: php-pspell support unavailable", FILE_APPEND);
return false;
}
if (isset($OVERRIDES['lang_default'])) { if (isset($OVERRIDES['lang_default'])) {
$lang = $OVERRIDES['lang_default']; $lang = $OVERRIDES['lang_default'];
@ -560,7 +565,7 @@ function get_suggestion($word)
$lang = 'en'; $lang = 'en';
} }
if(($pspell = pspell_new($lang)) == false) { if (($pspell = pspell_new($lang)) == false) {
file_put_contents($logfile, "\n" . logging_prefix() . " SEARCH: " . $lang . " dictionary not found", FILE_APPEND); file_put_contents($logfile, "\n" . logging_prefix() . " SEARCH: " . $lang . " dictionary not found", FILE_APPEND);
return false; return false;
} }
@ -585,7 +590,7 @@ function get_suggestion($word)
$return_string = ''; $return_string = '';
$words = explode(" ", $word); $words = explode(" ", $word);
foreach ($words as $one_word) { foreach ($words as $one_word) {
if(preg_match("/^(AND|OR|NOT|\+)$/i", $one_word)) { if (preg_match("/^(AND|OR|NOT|\+)$/i", $one_word)) {
$return_string .= $one_word . " "; $return_string .= $one_word . " ";
continue; continue;
} }