diff program/steps/mail/func.inc @ 19:b6a96bdd6b29

More cleaning up php8 Warnings/deprecations
author Charlie Root
date Wed, 08 Oct 2025 08:50:44 -0400
parents 1866b439e6d3
children 73124dd49283
line wrap: on
line diff
--- a/program/steps/mail/func.inc	Tue Oct 07 11:20:40 2025 -0400
+++ b/program/steps/mail/func.inc	Wed Oct 08 08:50:44 2025 -0400
@@ -78,7 +78,7 @@
     // set current mailbox and some other vars in client environment
     $OUTPUT->set_env('mailbox', $mbox_name);
     $OUTPUT->set_env('pagesize', $RCMAIL->storage->get_pagesize());
-    $OUTPUT->set_env('current_page', max(1, $_SESSION['page']));
+    $OUTPUT->set_env('current_page', max(1, ($_SESSION['page']??0)));
     $OUTPUT->set_env('delimiter', $delimiter);
     $OUTPUT->set_env('threading', $threading);
     $OUTPUT->set_env('threads', $threading || $RCMAIL->storage->get_capability('THREAD'));
@@ -163,22 +163,20 @@
     $message_sort_order = $RCMAIL->config->get('message_sort_order');
 
     // set imap properties and session vars
-    if (!strlen($mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GPC, true))) {
-        $mbox = strlen($_SESSION['mbox']) ? $_SESSION['mbox'] : 'INBOX';
-    }
+    $mbox = (rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GPC, true)??null) ?: (!empty($_SESSION['mbox']) ? $_SESSION['mbox'] : 'INBOX');
 
     // we handle 'page' argument on 'list' and 'getunread' to prevent from
     // race condition and unintentional page overwrite in session
     if ($RCMAIL->action == 'list' || $RCMAIL->action == 'getunread') {
-        if (!($page = intval($_GET['_page']))) {
-            $page = $_SESSION['page'] ?: 1;
+        if (!($page = intval($_GET['_page']??null))) {
+	  $page = ($_SESSION['page']??null) ?: 1;
         }
 
         $_SESSION['page'] = $page;
     }
 
     $RCMAIL->storage->set_folder($_SESSION['mbox'] = $mbox);
-    $RCMAIL->storage->set_page($_SESSION['page']);
+    $RCMAIL->storage->set_page($_SESSION['page']??null);
 
     // set default sort col/order to session
     if (!isset($_SESSION['sort_col'])) {
@@ -380,7 +378,7 @@
 
     $table = new html_table($attrib);
 
-    if (!$attrib['noheader']) {
+    if (empty($attrib['noheader'])) {
         foreach (rcmail_message_list_head($attrib, $a_show_cols) as $cell)
             $table->add_header(array('class' => $cell['className'], 'id' => $cell['id']), $cell['html']);
     }
@@ -459,7 +457,7 @@
         }
     }
 
-    $thead = $head_replace ? rcmail_message_list_head($_SESSION['list_attrib'], $a_show_cols) : NULL;
+    $thead = !empty($head_replace) ? rcmail_message_list_head($_SESSION['list_attrib'], $a_show_cols) : NULL;
 
     // get name of smart From/To column in folder context
     if (array_search('fromto', $a_show_cols) !== false) {
@@ -701,7 +699,7 @@
 {
     global $RCMAIL;
 
-    if (!$attrib['id']) {
+    if (empty($attrib['id'])) {
         $attrib['id'] = 'rcmcountdisplay';
     }
 
@@ -786,7 +784,7 @@
     // @TODO: this data is doubled (session and cache tables) if caching is enabled
 
     // Make sure we have an array here (#1487066)
-    if (!is_array($_SESSION['unseen_count'])) {
+    if (!is_array($_SESSION['unseen_count']??null)) {
         $_SESSION['unseen_count'] = array();
     }
 
@@ -795,7 +793,7 @@
 
 function rcmail_get_unseen_count($mbox_name)
 {
-    if (is_array($_SESSION['unseen_count']) && array_key_exists($mbox_name, $_SESSION['unseen_count'])) {
+    if (is_array($_SESSION['unseen_count']??null) && array_key_exists($mbox_name, $_SESSION['unseen_count'])) {
         return $_SESSION['unseen_count'][$mbox_name];
     }
 }
@@ -968,8 +966,8 @@
 
     // plaintext postprocessing
     if ($part->ctype_secondary == 'plain') {
-        $flowed = $part->ctype_parameters['format'] == 'flowed';
-        $delsp = $part->ctype_parameters['delsp'] == 'yes';
+      $flowed = ($part->ctype_parameters['format']??null) == 'flowed';
+        $delsp = ($part->ctype_parameters['delsp']??null) == 'yes';
         $body = rcmail_plain_body($body, $flowed, $delsp);
     }
 
@@ -1046,7 +1044,7 @@
     static $sa_attrib;
 
     // keep header table attrib
-    if (is_array($attrib) && !$sa_attrib && !$attrib['valueof']) {
+    if (is_array($attrib) && !$sa_attrib && empty($attrib['valueof'])) {
         $sa_attrib = $attrib;
     }
     else if (!is_array($attrib) && is_array($sa_attrib)) {
@@ -1073,15 +1071,15 @@
     // show these headers
     $standard_headers = array('subject', 'from', 'sender', 'to', 'cc', 'bcc', 'replyto',
         'mail-reply-to', 'mail-followup-to', 'date', 'priority');
-    $exclude_headers = $attrib['exclude'] ? explode(',', $attrib['exclude']) : array();
+    $exclude_headers = !empty($attrib['exclude']) ? explode(',', $attrib['exclude']) : array();
     $output_headers  = array();
 
     foreach ($standard_headers as $hkey) {
-        if ($headers[$hkey])
+        if ($headers[$hkey]??null)
             $value = $headers[$hkey];
-        else if ($headers['others'][$hkey])
+        else if ($headers['others'][$hkey]??null)
             $value = $headers['others'][$hkey];
-        else if (!$attrib['valueof'])
+        else if (empty($attrib['valueof']))
             continue;
 
         if (in_array($hkey, $exclude_headers))
@@ -1107,8 +1105,8 @@
         }
         else if ($hkey == 'replyto') {
             if ($headers['replyto'] != $headers['from']) {
-                $header_value = rcmail_address_string($value, $attrib['max'], true,
-                    $attrib['addicon'], $headers['charset'], $header_title);
+                $header_value = rcmail_address_string($value, $attrib['max']??null, true,
+                    $attrib['addicon']??null, $headers['charset'], $header_title);
                 $ishtml = true;
             }
             else {
@@ -1116,11 +1114,11 @@
             }
         }
         else if ($hkey == 'mail-reply-to') {
-            if ($headers['mail-replyto'] != $headers['replyto']
+	  if (($headers['mail-replyto']??null) != $headers['replyto']
                 && $headers['replyto'] != $headers['from']
             ) {
-                $header_value = rcmail_address_string($value, $attrib['max'], true,
-                    $attrib['addicon'], $headers['charset'], $header_title);
+                $header_value = rcmail_address_string($value, $attrib['max']??null, true,
+                    $attrib['addicon']??null, $headers['charset'], $header_title);
                 $ishtml = true;
             }
             else {
@@ -1128,9 +1126,9 @@
             }
         }
         else if ($hkey == 'sender') {
-            if ($headers['sender'] != $headers['from']) {
-                $header_value = rcmail_address_string($value, $attrib['max'], true,
-                    $attrib['addicon'], $headers['charset'], $header_title);
+	  if (($headers['sender']??null) != $headers['from']) {
+                $header_value = rcmail_address_string($value, $attrib['max']??null, true,
+                    $attrib['addicon']??null, $headers['charset'], $header_title);
                 $ishtml = true;
             }
             else {
@@ -1138,13 +1136,14 @@
             }
         }
         else if ($hkey == 'mail-followup-to') {
-            $header_value = rcmail_address_string($value, $attrib['max'], true,
-                $attrib['addicon'], $headers['charset'], $header_title);
+            $header_value = rcmail_address_string($value, $attrib['max']??null,
+						  true,
+                $attrib['addicon']??null, $headers['charset'], $header_title);
             $ishtml = true;
         }
         else if (in_array($hkey, array('from', 'to', 'cc', 'bcc'))) {
-            $header_value = rcmail_address_string($value, $attrib['max'], true,
-                $attrib['addicon'], $headers['charset'], $header_title);
+            $header_value = rcmail_address_string($value, $attrib['max']??null, true,
+                $attrib['addicon']??null, $headers['charset'], $header_title);
             $ishtml = true;
         }
         else if ($hkey == 'subject' && empty($value)) {
@@ -1205,7 +1204,7 @@
         '5' => 'lowest',
     );
 
-    if ($value && $labels_map[$value]) {
+    if ($value && !empty($labels_map[$value])) {
         return $RCMAIL->gettext($labels_map[$value]);
     }
 
@@ -1249,7 +1248,7 @@
     if (!$attrib['id'])
         $attrib['id'] = 'rcmailMsgBody';
 
-    $safe_mode = $MESSAGE->is_safe || intval($_GET['_safe']);
+    $safe_mode = $MESSAGE->is_safe || intval($_GET['_safe']??null);
     $out       = '';
     $part_no   = 0;
 
@@ -1267,7 +1266,7 @@
             }
             else if ($part->type == 'content') {
                 // unsupported (e.g. encrypted)
-                if ($part->realtype) {
+                if ($part->realtype??null) {
                     if ($part->realtype == 'multipart/encrypted' || $part->realtype == 'application/pkcs7-mime') {
                         if (!empty($_SESSION['browser_caps']['pgpmime']) && ($pgp_mime_part = $MESSAGE->get_multipart_encrypted_part())) {
                             $out .= html::span('part-notice', $RCMAIL->gettext('externalmessagedecryption'));
@@ -2136,7 +2135,7 @@
 
     $RCMAIL->output->add_gui_object('search_filter', $attrib['id']);
 
-    return $select->show($_REQUEST['_search'] ? $_SESSION['search_filter'] : 'ALL');
+    return $select->show(($_REQUEST['_search']??null) ? $_SESSION['search_filter'] : 'ALL');
 }
 
 function rcmail_search_interval($attrib)
@@ -2156,7 +2155,7 @@
 
     $RCMAIL->output->add_gui_object('search_interval', $attrib['id']);
 
-    return $select->show($_REQUEST['_search'] ? $_SESSION['search_interval'] : '');
+    return $select->show(($_REQUEST['_search']??null) ? $_SESSION['search_interval'] : '');
 }
 
 function rcmail_message_error()