Mercurial > hg > rc2
changeset 21:73124dd49283
More cleaning up php8 Warnings/deprecations,
noticed that setting non-my-Dates mailboxes to sort on Date isn't sticky over ctrl-R
| author | Charlie Root |
|---|---|
| date | Thu, 09 Oct 2025 11:31:41 -0400 |
| parents | 4aec5e272733 |
| children | 303b85d5b561 |
| files | program/include/rcmail.php program/lib/Roundcube/bootstrap.php program/lib/Roundcube/html.php program/lib/Roundcube/rcube.php program/lib/Roundcube/rcube_imap.php program/lib/Roundcube/rcube_imap_generic.php program/lib/Roundcube/rcube_message_header.php program/lib/Roundcube/rcube_plugin_api.php program/lib/Roundcube/rcube_utils.php program/lib/Roundcube/rcube_vcard.php program/lib/Roundcube/rcube_washtml.php program/steps/addressbook/func.inc program/steps/addressbook/photo.inc program/steps/mail/check_recent.inc program/steps/mail/func.inc program/steps/mail/show.inc |
| diffstat | 16 files changed, 94 insertions(+), 86 deletions(-) [+] |
line wrap: on
line diff
--- a/program/include/rcmail.php Wed Oct 08 09:42:21 2025 -0400 +++ b/program/include/rcmail.php Thu Oct 09 11:31:41 2025 -0400 @@ -1334,7 +1334,7 @@ $attrib += array('maxlength' => 100, 'realnames' => false, 'unreadwrap' => ' (%s)'); - $type = $attrib['type'] ? $attrib['type'] : 'ul'; + $type = ($attrib['type']??null) ?: 'ul'; unset($attrib['type']); if ($type == 'ul' && !$attrib['id']) { @@ -2184,7 +2184,7 @@ $content .= $hint; } - if (rcube_utils::get_boolean($attrib['buttons'])) { + if (rcube_utils::get_boolean($attrib['buttons']??null)) { $button = new html_inputfield(array('type' => 'button')); $content .= html::div('buttons', $button->show($this->gettext('close'), array('class' => 'button', 'onclick' => "$('#{$attrib['id']}').hide()")) . ' ' .
--- a/program/lib/Roundcube/bootstrap.php Wed Oct 08 09:42:21 2025 -0400 +++ b/program/lib/Roundcube/bootstrap.php Thu Oct 09 11:31:41 2025 -0400 @@ -287,7 +287,7 @@ 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, ($str??'')); } /**
--- a/program/lib/Roundcube/html.php Wed Oct 08 09:42:21 2025 -0400 +++ b/program/lib/Roundcube/html.php Thu Oct 09 11:31:41 2025 -0400 @@ -417,7 +417,7 @@ $this->attrib = $attrib; } - if ($attrib['type']) { + if ($attrib['type']??null) { $this->type = $attrib['type']; } } @@ -899,7 +899,7 @@ } } - if ($this->attrib['rowsonly']) { + if ($this->attrib['rowsonly']??null) { return $tbody; }
--- a/program/lib/Roundcube/rcube.php Wed Oct 08 09:42:21 2025 -0400 +++ b/program/lib/Roundcube/rcube.php Thu Oct 09 11:31:41 2025 -0400 @@ -625,7 +625,7 @@ if ($domain && ($text = $this->texts[$domain.'.'.$name])) { } // text does not exist - else if (!($text = $this->texts[$name])) { + else if (!($text = ($this->texts[$name]??null))) { return "[$name]"; } // replace vars in text
--- a/program/lib/Roundcube/rcube_imap.php Wed Oct 08 09:42:21 2025 -0400 +++ b/program/lib/Roundcube/rcube_imap.php Thu Oct 09 11:31:41 2025 -0400 @@ -57,6 +57,7 @@ protected $icache = array(); protected $plugins; + protected $parts; protected $delimiter; protected $namespace; protected $sort_field = ''; @@ -1812,7 +1813,7 @@ list($uid, $folder) = explode('-', $uid, 2); } - if (!strlen($folder)) { + if (empty($folder)) { $folder = $this->folder; } @@ -1845,7 +1846,7 @@ */ public function get_message($uid, $folder = null) { - if (!strlen($folder)) { + if (!empty($folder)) { $folder = $this->folder; } @@ -2028,7 +2029,7 @@ // pre-fetch headers of all parts (in one command for better performance) // @TODO: we could do this before _structure_part() call, to fetch // headers for parts on all levels - if ($mime_part_headers) { + if (!empty($mime_part_headers)) { $mime_part_headers = $this->conn->fetchMIMEHeaders($this->folder, $this->msg_uid, $mime_part_headers); } @@ -2040,7 +2041,7 @@ } $tmp_part_id = $struct->mime_id ? $struct->mime_id.'.'.($i+1) : $i+1; $struct->parts[] = $this->structure_part($part[$i], ++$count, $struct->mime_id, - $mime_part_headers ? $mime_part_headers[$tmp_part_id] : null); + empty($mime_part_headers[$tmp_part_id]) ? null : $mime_part_headers[$tmp_part_id]) ; } return $struct; @@ -2144,7 +2145,7 @@ } // fetch message headers if message/rfc822 or named part (could contain Content-Location header) - if ($struct->ctype_primary == 'message' || ($struct->ctype_parameters['name'] && !$struct->content_id)) { + if ($struct->ctype_primary == 'message' || (!empty($struct->ctype_parameters['name']) && !$struct->content_id)) { if (empty($mime_headers)) { $mime_headers = $this->conn->fetchPartHeader( $this->folder, $this->msg_uid, true, $struct->mime_id);
--- a/program/lib/Roundcube/rcube_imap_generic.php Wed Oct 08 09:42:21 2025 -0400 +++ b/program/lib/Roundcube/rcube_imap_generic.php Thu Oct 09 11:31:41 2025 -0400 @@ -2783,7 +2783,7 @@ $binary = true; do { - if (!$initiated) { + if (empty($initiated)) { switch ($encoding) { case 'base64': $mode = 1;
--- a/program/lib/Roundcube/rcube_message_header.php Wed Oct 08 09:42:21 2025 -0400 +++ b/program/lib/Roundcube/rcube_message_header.php Thu Oct 09 11:31:41 2025 -0400 @@ -252,7 +252,7 @@ $value = $this->{$this->obj_headers[$name]}; } else { - $value = $this->others[$name]; + $value = $this->others[$name]??null; } if ($decode) {
--- a/program/lib/Roundcube/rcube_plugin_api.php Wed Oct 08 09:42:21 2025 -0400 +++ b/program/lib/Roundcube/rcube_plugin_api.php Thu Oct 09 11:31:41 2025 -0400 @@ -622,7 +622,7 @@ */ public function add_content($html, $container) { - $this->template_contents[$container] .= $html . "\n"; + $this->template_contents[$container] = ($this->template_contents[$container]??'') . $html . "\n"; } /** @@ -654,7 +654,7 @@ protected function template_container_hook($attrib) { $container = $attrib['name']; - return array('content' => ($attrib['content']??'') . $this->template_contents[$container]); + return array('content' => ($attrib['content']??'') . ($this->template_contents[$container]??'')); } /**
--- a/program/lib/Roundcube/rcube_utils.php Wed Oct 08 09:42:21 2025 -0400 +++ b/program/lib/Roundcube/rcube_utils.php Thu Oct 09 11:31:41 2025 -0400 @@ -665,7 +665,7 @@ $hdrs = array_change_key_case($_SERVER, CASE_UPPER); } - return $hdrs[$key]; + return ($hdrs[$key]??null); } /** @@ -1088,11 +1088,12 @@ * * @return boolean Boolean value */ - public static function get_boolean($str) + public static function get_boolean($str = '') { - $str = strtolower($str); + if (empty($str)) return false; + $str = strtolower($str); - return !in_array($str, array('false', '0', 'no', 'off', 'nein', ''), true); + return !in_array($str, array('false', '0', 'no', 'off', 'nein'), true); } /**
--- a/program/lib/Roundcube/rcube_vcard.php Wed Oct 08 09:42:21 2025 -0400 +++ b/program/lib/Roundcube/rcube_vcard.php Thu Oct 09 11:31:41 2025 -0400 @@ -129,8 +129,8 @@ $this->surname = $this->raw['N'][0][0]; $this->firstname = $this->raw['N'][0][1]; $this->middlename = $this->raw['N'][0][2]; - $this->nickname = $this->raw['NICKNAME'][0][0]; - $this->organization = $this->raw['ORG'][0][0]; + $this->nickname = empty($this->raw['NICKNAME']) ? null : $this->raw['NICKNAME'][0][0]; + $this->organization = empty($this->raw['ORG']) ? null : $this->raw['ORG'][0][0]; $this->business = ($this->raw['X-ABSHOWAS'][0][0] == 'COMPANY') || (join('', (array)$this->raw['N'][0]) == '' && !empty($this->organization)); foreach ((array)$this->raw['EMAIL'] as $i => $raw_email) { @@ -163,7 +163,7 @@ // copy name fields to output array foreach (array('firstname','surname','middlename','nickname','organization') as $col) { - if (strlen($this->$col)) { + if (!empty($this->$col) && strlen($this->$col)) { $out[$col] = $this->$col; } } @@ -175,66 +175,68 @@ // convert from raw vcard data into associative data for Roundcube foreach (array_flip(self::$fieldmap) as $tag => $col) { - foreach ((array)$this->raw[$tag] as $i => $raw) { - if (is_array($raw)) { - $k = -1; - $key = $col; - $subtype = ''; + if (!empty($this->raw[$tag])) { + foreach ((array)$this->raw[$tag] as $i => $raw) { + if (is_array($raw)) { + $k = -1; + $key = $col; + $subtype = ''; - if (!empty($raw['type'])) { - $combined = join(',', self::array_filter((array)$raw['type'], 'internet,pref', true)); - $combined = strtoupper($combined); + if (!empty($raw['type'])) { + $combined = join(',', self::array_filter((array)$raw['type'], 'internet,pref', true)); + $combined = strtoupper($combined); - if ($typemap[$combined]) { - $subtype = $typemap[$combined]; - } - else if ($typemap[$raw['type'][++$k]]) { - $subtype = $typemap[$raw['type'][$k]]; - } - else { - $subtype = strtolower($raw['type'][$k]); - } + if ($typemap[$combined]) { + $subtype = $typemap[$combined]; + } + else if ($typemap[$raw['type'][++$k]]) { + $subtype = $typemap[$raw['type'][$k]]; + } + else { + $subtype = strtolower($raw['type'][$k]); + } - while ($k < count($raw['type']) && ($subtype == 'internet' || $subtype == 'pref')) { - $subtype = $typemap[$raw['type'][++$k]] ?: strtolower($raw['type'][$k]); - } - } + while ($k < count($raw['type']) && ($subtype == 'internet' || $subtype == 'pref')) { + $subtype = $typemap[$raw['type'][++$k]] ?: strtolower($raw['type'][$k]); + } + } - // read vcard 2.1 subtype - if (!$subtype) { - foreach ($raw as $k => $v) { - if (!is_numeric($k) && $v === true && ($k = strtolower($k)) - && !in_array($k, array('pref','internet','voice','base64')) - ) { - $k_uc = strtoupper($k); - $subtype = $typemap[$k_uc] ?: $k; - break; - } - } - } + // read vcard 2.1 subtype + if (!$subtype) { + foreach ($raw as $k => $v) { + if (!is_numeric($k) && $v === true && ($k = strtolower($k)) + && !in_array($k, array('pref','internet','voice','base64')) + ) { + $k_uc = strtoupper($k); + $subtype = $typemap[$k_uc] ?: $k; + break; + } + } + } - // force subtype if none set - if (!$subtype && preg_match('/^(email|phone|address|website)/', $key)) { - $subtype = 'other'; - } + // force subtype if none set + if (!$subtype && preg_match('/^(email|phone|address|website)/', $key)) { + $subtype = 'other'; + } - if ($subtype) { - $key .= ':' . $subtype; - } + if ($subtype) { + $key .= ':' . $subtype; + } - // split ADR values into assoc array - if ($tag == 'ADR') { - list(,, $value['street'], $value['locality'], $value['region'], $value['zipcode'], $value['country']) = $raw; - $out[$key][] = $value; - } - else { - $out[$key][] = $raw[0]; - } - } - else { - $out[$col][] = $raw; - } - } + // split ADR values into assoc array + if ($tag == 'ADR') { + list(,, $value['street'], $value['locality'], $value['region'], $value['zipcode'], $value['country']) = $raw; + $out[$key][] = $value; + } + else { + $out[$key][] = $raw[0]; + } + } + else { + $out[$col][] = $raw; + } + } + } } // handle special IM fields as used by Apple @@ -611,7 +613,7 @@ } // convert 2.1-style "EMAIL;internet;home:" to 3.0-style "EMAIL;TYPE=internet;TYPE=home:" - if ($result['VERSION'][0] == "2.1" + if (!empty($result['VERSION']) && $result['VERSION'][0] == "2.1" && preg_match('/^([^;]+);([^:]+)/', $prefix, $regs2) && !preg_match('/^TYPE=/i', $regs2[2]) ) { @@ -621,7 +623,8 @@ } } - if (preg_match_all('/([^\\;]+);?/', $prefix, $regs2)) { + if (preg_match_all('/([^\\;]+);?/', $prefix, $regs2) && + count($regs2) > 0) { $entry = array(); $field = strtoupper($regs2[1][0]); $enc = null;
--- a/program/lib/Roundcube/rcube_washtml.php Wed Oct 08 09:42:21 2025 -0400 +++ b/program/lib/Roundcube/rcube_washtml.php Thu Oct 09 11:31:41 2025 -0400 @@ -438,7 +438,7 @@ if ($this->max_nesting_level > 0 && $level == $this->max_nesting_level - 1) { // log error message once - if (!$this->max_nesting_level_error) { + if (empty($this->max_nesting_level_error)) { $this->max_nesting_level_error = true; rcube::raise_error(array('code' => 500, 'type' => 'php', 'line' => __LINE__, 'file' => __FILE__,
--- a/program/steps/addressbook/func.inc Wed Oct 08 09:42:21 2025 -0400 +++ b/program/steps/addressbook/func.inc Thu Oct 09 11:31:41 2025 -0400 @@ -101,7 +101,7 @@ } // remove undo information... -if ($undo = $_SESSION['contact_undo']) { +if ($undo = ($_SESSION['contact_undo']??null)) { // ...after timeout $undo_time = $RCMAIL->config->get('undo_timeout', 0); if ($undo['ts'] < time() - $undo_time) @@ -945,7 +945,8 @@ return $cid; } - if (!preg_match('/^[a-zA-Z0-9\+\/=_-]+(,[a-zA-Z0-9\+\/=_-]+)*$/', $cid)) { + if (!preg_match('/^[a-zA-Z0-9\+\/=_-]+(,[a-zA-Z0-9\+\/=_-]+)*$/', + ($cid??''))) { return array(); }
--- a/program/steps/addressbook/photo.inc Wed Oct 08 09:42:21 2025 -0400 +++ b/program/steps/addressbook/photo.inc Thu Oct 09 11:31:41 2025 -0400 @@ -24,6 +24,7 @@ $cids = rcmail_get_cids(); $source = key($cids); $cid = $cids ? array_shift($cids[$source]) : null; +$data = ''; // read the referenced file if (($file_id = rcube_utils::get_input_value('_photo', rcube_utils::INPUT_GPC)) && ($tempfile = $_SESSION['contacts']['files'][$file_id])) { @@ -57,7 +58,7 @@ $record = $CONTACTS->get_record($cid, true); } - if ($record['photo']) { + if (!empty($record) && $record['photo']) { $data = is_array($record['photo']) ? $record['photo'][0] : $record['photo']; if (!preg_match('![^a-z0-9/=+-]!i', $data)) $data = base64_decode($data, true); @@ -69,7 +70,7 @@ array('record' => $record, 'email' => $email, 'data' => $data)); // redirect to url provided by a plugin -if ($plugin['url']) { +if ($plugin['url']??null) { $RCMAIL->output->redirect($plugin['url']); }
--- a/program/steps/mail/check_recent.inc Wed Oct 08 09:42:21 2025 -0400 +++ b/program/steps/mail/check_recent.inc Thu Oct 09 11:31:41 2025 -0400 @@ -131,7 +131,7 @@ $data = $RCMAIL->storage->folder_data($mbox_name); if (empty($_SESSION['list_mod_seq']) || $_SESSION['list_mod_seq'] != $data['HIGHESTMODSEQ']) { - $flags = $RCMAIL->storage->list_flags($mbox_name, explode(',', $uids), $_SESSION['list_mod_seq']); + $flags = $RCMAIL->storage->list_flags($mbox_name, explode(',', $uids), ($_SESSION['list_mod_seq']??null)); foreach ($flags as $idx => $row) { $flags[$idx] = array_change_key_case(array_map('intval', $row)); }
--- a/program/steps/mail/func.inc Wed Oct 08 09:42:21 2025 -0400 +++ b/program/steps/mail/func.inc Thu Oct 09 11:31:41 2025 -0400 @@ -565,7 +565,8 @@ } if ($RCMAIL->storage->get_threading()) { - $OUTPUT->command('init_threads', (array) $roots, $mbox); + $OUTPUT->command('init_threads', isset($roots) ? (array)$roots: array(), + $mbox); } }
--- a/program/steps/mail/show.inc Wed Oct 08 09:42:21 2025 -0400 +++ b/program/steps/mail/show.inc Thu Oct 09 11:31:41 2025 -0400 @@ -47,7 +47,7 @@ $RCMAIL->config->set('prefer_html', $_SESSION['msg_formats'][$mbox_name.':'.$uid]); } - $MESSAGE = new rcube_message($msg_id, $mbox_name, intval($_GET['_safe'])); + $MESSAGE = new rcube_message($msg_id, $mbox_name, intval($_GET['_safe']??null)); // if message not found (wrong UID)... if (empty($MESSAGE->headers)) { @@ -326,7 +326,7 @@ { global $RCMAIL, $MESSAGE; - $placeholder = $attrib['placeholder'] ? $RCMAIL->output->abs_url($attrib['placeholder'], true) : null; + $placeholder = !empty($attrib['placeholder']) ? $RCMAIL->output->abs_url($attrib['placeholder'], true) : null; $placeholder = $RCMAIL->output->asset_url($placeholder ?: 'program/resources/blank.gif'); if ($MESSAGE->sender) {
