Browse Source

Fix some PHP8 compatibility issues (#8363)

pull/8503/head
Aleksander Machniak 4 years ago
parent
commit
918730b46f
  1. 1
      CHANGELOG.md
  2. 8
      program/actions/mail/compose.php
  3. 5
      program/actions/mail/search_contacts.php
  4. 8
      program/actions/mail/send.php
  5. 4
      program/include/rcmail_action.php
  6. 2
      program/include/rcmail_sendmail.php
  7. 8
      program/lib/Roundcube/bootstrap.php
  8. 4
      program/lib/Roundcube/rcube_plugin_api.php

1
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

8
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

5
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)

8
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');

4
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']);
}
}

2
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');

8
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;
}
}

4
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']];

Loading…
Cancel
Save