diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c72d37f1..1691091ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Fix password change with Directadmin driver (#8322, #8329) - Fix so css files in plugins/jqueryui/themes will be minified too (#8337) - Fix handling of unicode/special characters in custom From input (#8357) +- Fix some PHP8 compatibility issues (#8363) ## Release 1.5.1 diff --git a/program/actions/mail/compose.php b/program/actions/mail/compose.php index 1301780c2..3dc247d8d 100644 --- a/program/actions/mail/compose.php +++ b/program/actions/mail/compose.php @@ -689,6 +689,14 @@ class rcmail_action_mail_compose extends rcmail_action_mail_index return $body; } + /** + * Prepare message (or message part) body for composition + * + * @param rcube_message|rcube_message_part $part Message or message part object + * @param bool $isHtml Use HTML mode + * + * @return string Message body text + */ public static function compose_part_body($part, $isHtml = false) { // Check if we have enough memory to handle the message in it diff --git a/program/actions/mail/search_contacts.php b/program/actions/mail/search_contacts.php index 5061fa4ac..c9f7e70b4 100644 --- a/program/actions/mail/search_contacts.php +++ b/program/actions/mail/search_contacts.php @@ -87,8 +87,9 @@ class rcmail_action_mail_search_contacts extends rcmail_action_mail_list_contact // create javascript list while ($row = $result->next()) { $name = rcube_addressbook::compose_list_name($row); - $classname = $row['_type'] == 'group' ? 'group' : 'person'; - $keyname = $row['_type'] == 'group' ? 'contactgroup' : 'contact'; + $is_group = isset($row['_type']) && $row['_type'] == 'group'; + $classname = $is_group ? 'group' : 'person'; + $keyname = $is_group ? 'contactgroup' : 'contact'; // add record for every email address of the contact // (same as in list_contacts.inc) diff --git a/program/actions/mail/send.php b/program/actions/mail/send.php index ae199d797..b8edf16c9 100644 --- a/program/actions/mail/send.php +++ b/program/actions/mail/send.php @@ -366,6 +366,9 @@ class rcmail_action_mail_send extends rcmail_action $is_inline = preg_match($dispurl, $message_body); } + $ctype = isset($attachment['mimetype']) ? $attachment['mimetype'] : ''; + $ctype = str_replace('image/pjpeg', 'image/jpeg', $ctype); // #1484914 + // inline image if ($is_inline) { // Mail_Mime does not support many inline attachments with the same name (#1489406) @@ -392,14 +395,13 @@ class rcmail_action_mail_send extends rcmail_action } if (!empty($attachment['data'])) { - $message->addHTMLImage($attachment['data'], $attachment['mimetype'], $attachment['name'], false, $cid); + $message->addHTMLImage($attachment['data'], $ctype, $attachment['name'], false, $cid); } else { - $message->addHTMLImage($attachment['path'], $attachment['mimetype'], $attachment['name'], true, $cid); + $message->addHTMLImage($attachment['path'], $ctype, $attachment['name'], true, $cid); } } else { - $ctype = str_replace('image/pjpeg', 'image/jpeg', $attachment['mimetype']); // #1484914 $file = !empty($attachment['data']) ? $attachment['data'] : $attachment['path']; $folding = (int) $rcmail->config->get('mime_param_folding'); diff --git a/program/include/rcmail_action.php b/program/include/rcmail_action.php index a767fa3ac..110515513 100644 --- a/program/include/rcmail_action.php +++ b/program/include/rcmail_action.php @@ -683,10 +683,10 @@ abstract class rcmail_action header('Content-Type: ' . $file['mimetype']); header('Content-Length: ' . $file['size']); - if ($file['data']) { + if (isset($file['data']) && is_string($file['data'])) { echo $file['data']; } - else if ($file['path']) { + else if (!empty($file['path'])) { readfile($file['path']); } } diff --git a/program/include/rcmail_sendmail.php b/program/include/rcmail_sendmail.php index b94aa784d..e9337ecc2 100644 --- a/program/include/rcmail_sendmail.php +++ b/program/include/rcmail_sendmail.php @@ -1353,7 +1353,7 @@ class rcmail_sendmail $mdn_default = $_POST['_mdn']; } else if (in_array($this->data['mode'], [self::MODE_DRAFT, self::MODE_EDIT])) { - $mdn_default = (bool) $this->options['message']->headers->mdn_to; + $mdn_default = !empty($this->options['message']->headers->mdn_to); } else { $mdn_default = $this->rcmail->config->get('mdn_default'); diff --git a/program/lib/Roundcube/bootstrap.php b/program/lib/Roundcube/bootstrap.php index 17b143631..6aaa444fa 100644 --- a/program/lib/Roundcube/bootstrap.php +++ b/program/lib/Roundcube/bootstrap.php @@ -113,10 +113,14 @@ PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, function($err) { rcube::raise_error( */ function in_array_nocase($needle, $haystack) { + if (!is_string($heystack)) { + return false; + } + // use much faster method for ascii if (is_ascii($needle)) { foreach ((array) $haystack as $value) { - if (strcasecmp($value, $needle) === 0) { + if (is_string($value) && strcasecmp($value, $needle) === 0) { return true; } } @@ -124,7 +128,7 @@ function in_array_nocase($needle, $haystack) else { $needle = mb_strtolower($needle); foreach ((array) $haystack as $value) { - if ($needle === mb_strtolower($value)) { + if (is_string($value) && $needle === mb_strtolower($value)) { return true; } } diff --git a/program/lib/Roundcube/rcube_plugin_api.php b/program/lib/Roundcube/rcube_plugin_api.php index 748673d55..ad305fd67 100644 --- a/program/lib/Roundcube/rcube_plugin_api.php +++ b/program/lib/Roundcube/rcube_plugin_api.php @@ -368,7 +368,7 @@ class rcube_plugin_api // read local composer.lock file (once) if (!isset($composer_lock)) { $composer_lock = @json_decode(@file_get_contents(INSTALL_PATH . "/composer.lock"), true); - if ($composer_lock['packages']) { + if ($composer_lock && !empty($composer_lock['packages'])) { foreach ($composer_lock['packages'] as $i => $package) { $composer_lock['installed'][$package['name']] = $package; } @@ -376,7 +376,7 @@ class rcube_plugin_api } // load additional information from local composer.lock file - if (!empty($json['name']) && !empty($composer_lock['installed']) + if (!empty($json['name']) && $composer_lock && !empty($composer_lock['installed']) && !empty($composer_lock['installed'][$json['name']]) ) { $lock = $composer_lock['installed'][$json['name']];