fix PHP 8.0 TypeError: strlen(): Argument #1 ($str) must be of type string, array given

This commit is contained in:
Ralf Becker 2021-11-10 15:23:25 +01:00
parent 050bf162d9
commit 78f58a887d

View File

@ -431,12 +431,13 @@ class admin_mail
'acc_folder_archive' => array('', 'archive'), 'acc_folder_archive' => array('', 'archive'),
) as $name => $common_names) ) as $name => $common_names)
{ {
unset($content[$name]);
// first check special-use attributes // first check special-use attributes
if (($special_use = array_shift($common_names))) if (($special_use = array_shift($common_names)))
{ {
foreach((array)$attributes[$special_use] as $mailbox) foreach((array)$attributes[$special_use] as $mailbox)
{ {
if (empty($content[$name]) || strlen($mailbox) < strlen($content[$name])) if (empty($content[$name]) || is_string($mailbox) && strlen($mailbox) < strlen($content[$name]))
{ {
$content[$name] = $mailbox; $content[$name] = $mailbox;
} }
@ -450,7 +451,7 @@ class admin_mail
$delimiter = !empty($data['delimiter']) ? $data['delimiter'] : '.'; $delimiter = !empty($data['delimiter']) ? $data['delimiter'] : '.';
$name_parts = explode($delimiter, strtolower($mailbox)); $name_parts = explode($delimiter, strtolower($mailbox));
if (array_intersect($name_parts, $common_names) && if (array_intersect($name_parts, $common_names) &&
(empty($content[$name]) || strlen($mailbox) < strlen($content[$name]) && substr($content[$name], 0, 6) != 'INBOX'.$delimiter)) (empty($content[$name]) || is_string($mailbox) && strlen($mailbox) < strlen($content[$name]) && substr($content[$name], 0, 6) != 'INBOX'.$delimiter))
{ {
//error_log(__METHOD__."() $mailbox --> ".substr($name, 11).' folder'); //error_log(__METHOD__."() $mailbox --> ".substr($name, 11).' folder');
$content[$name] = $mailbox; $content[$name] = $mailbox;