Fix PHP8 warnings

This commit is contained in:
Aleksander Machniak
2024-05-19 11:04:47 +02:00
parent a8e2477dbe
commit 5c0fbde168
2 changed files with 4 additions and 4 deletions

View File

@@ -326,7 +326,7 @@ function array_first($array)
function asciiwords($str, $css_id = false, $replace_with = '')
{
$allowed = 'a-z0-9\_\-' . (!$css_id ? '\.' : '');
return preg_replace("/[^$allowed]+/i", $replace_with, $str);
return preg_replace("/[^$allowed]+/i", $replace_with, (string) $str);
}
/**
@@ -340,7 +340,7 @@ function asciiwords($str, $css_id = false, $replace_with = '')
function is_ascii($str, $control_chars = true)
{
$regexp = $control_chars ? '/[^\x00-\x7F]/' : '/[^\x20-\x7E]/';
return preg_match($regexp, $str) ? false : true;
return preg_match($regexp, (string) $str) ? false : true;
}
/**

View File

@@ -833,7 +833,7 @@ class rcube
$lang = $rcube_language_aliases[$lang];
}
// try the first two chars
else if (!isset($rcube_languages[$lang])) {
else if ($lang && !isset($rcube_languages[$lang])) {
$short = substr($lang, 0, 2);
// check if we have an alias for the short language code
@@ -846,7 +846,7 @@ class rcube
}
}
if (!isset($rcube_languages[$lang]) || !is_dir(RCUBE_LOCALIZATION_DIR . $lang)) {
if (!$lang || !isset($rcube_languages[$lang]) || !is_dir(RCUBE_LOCALIZATION_DIR . $lang)) {
$lang = 'en_US';
}