diff options
author | Aleksander Machniak <alec@alec.pl> | 2022-06-25 09:33:03 +0300 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2022-06-25 09:33:03 +0300 |
commit | e2472092805d3946bd6efab661edd613342a0283 (patch) | |
tree | 4dd4e6b373dd123d444e45b2b658bd5905ddb1f7 | |
parent | 42f9cdceba17597fca5c9e18cd5154158ad9db87 (diff) |
Fix various PHP 8.1 warnings (#8584)
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | program/actions/mail/show.php | 2 | ||||
-rw-r--r-- | program/lib/Roundcube/rcube.php | 6 | ||||
-rw-r--r-- | program/lib/Roundcube/rcube_string_replacer.php | 4 |
4 files changed, 11 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 282de1d10..557c48ce0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Fix bug where some checkboxes could be selected unintentinally (#8565) - Fix css styles of the email recipient element while dragging (#8580) - Fix PHP 8.1 warnings in the LDAP backend code (#8572) +- Fix various PHP 8.1 warnings (#8584) ## Release 1.6-rc diff --git a/program/actions/mail/show.php b/program/actions/mail/show.php index beedd78fd..9c81aadf1 100644 --- a/program/actions/mail/show.php +++ b/program/actions/mail/show.php @@ -763,7 +763,7 @@ class rcmail_action_mail_show extends rcmail_action_mail_index else { // Check if we have enough memory to handle the message in it // #1487424: we need up to 10x more memory than the body - if (!rcube_utils::mem_check(strlen(self::$MESSAGE->body) * 10)) { + if (isset(self::$MESSAGE->body) && !rcube_utils::mem_check(strlen(self::$MESSAGE->body) * 10)) { $out .= self::part_too_big_message(self::$MESSAGE, 0); } else { diff --git a/program/lib/Roundcube/rcube.php b/program/lib/Roundcube/rcube.php index bc3fd0038..1b4579069 100644 --- a/program/lib/Roundcube/rcube.php +++ b/program/lib/Roundcube/rcube.php @@ -605,7 +605,11 @@ class rcube // replace vars in text if (!empty($attrib['vars']) && is_array($attrib['vars'])) { foreach ($attrib['vars'] as $var_key => $var_value) { - $text = str_replace($var_key[0] != '$' ? '$'.$var_key : $var_key, $var_value, $text); + if ($var_key[0] != '$') { + $var_key = '$' . $var_key; + } + + $text = str_replace($var_key, $var_value ?? '', $text); } } diff --git a/program/lib/Roundcube/rcube_string_replacer.php b/program/lib/Roundcube/rcube_string_replacer.php index cbbffcd55..b1b7fcb9e 100644 --- a/program/lib/Roundcube/rcube_string_replacer.php +++ b/program/lib/Roundcube/rcube_string_replacer.php @@ -221,6 +221,10 @@ class rcube_string_replacer */ public function replace($str) { + if (!is_string($str)) { + return ''; + } + // search for patterns like links and e-mail addresses $str = preg_replace_callback($this->link_pattern, [$this, 'link_callback'], $str); $str = preg_replace_callback($this->mailto_pattern, [$this, 'mailto_callback'], $str); |