changeset 58:082a19037887 default tip

More cleaning up php8 Warnings/deprecations
author Charlie Root
date Wed, 15 Oct 2025 14:06:01 -0400
parents ade98a608cd3
children
files etc/config.inc.php index.php plugins/calendar/calendar.php plugins/filesystem_attachments/filesystem_attachments.php plugins/jqueryui/jqueryui.php plugins/libcalendaring/libcalendaring.php plugins/libcalendaring/libvcalendar.php plugins/managesieve/managesieve.php
diffstat 8 files changed, 18 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/etc/config.inc.php	Wed Oct 08 09:33:13 2025 -0400
+++ b/etc/config.inc.php	Wed Oct 15 14:06:01 2025 -0400
@@ -109,7 +109,7 @@
 	'managesieve',
 	'thunderbird_labels',
 	'contextmenu',
-	//'libcalendaring',
+	'libcalendaring',
 	'calendar',
 	'password',
 	'advanced_search',
--- a/index.php	Wed Oct 08 09:33:13 2025 -0400
+++ b/index.php	Wed Oct 15 14:06:01 2025 -0400
@@ -222,7 +222,7 @@
         $session_error = true;
     }
 
-    if ($session_error || $_REQUEST['_err'] == 'session') {
+    if ($session_error || ($_REQUEST['_err']??null) == 'session') {
         $OUTPUT->show_message('sessionerror', 'error', null, true, -1);
     }
 
--- a/plugins/calendar/calendar.php	Wed Oct 08 09:33:13 2025 -0400
+++ b/plugins/calendar/calendar.php	Wed Oct 15 14:06:01 2025 -0400
@@ -126,7 +126,7 @@
     $this->setup();
 
     // load Calendar user interface
-    if (!$this->rc->output->ajax_call && (!$this->rc->output->env['framed'] || $args['action'] == 'preview')) {
+    if (!$this->rc->output->ajax_call && (empty($this->rc->output->env['framed']) || $args['action'] == 'preview')) {
       $this->ui->init();
 
       // settings are required in (almost) every GUI step
--- a/plugins/filesystem_attachments/filesystem_attachments.php	Wed Oct 08 09:33:13 2025 -0400
+++ b/plugins/filesystem_attachments/filesystem_attachments.php	Wed Oct 15 14:06:01 2025 -0400
@@ -151,7 +151,7 @@
         // $_SESSION['compose']['attachments'] is not a complete record of
         // temporary files because loading a draft or starting a forward copies
         // the file to disk, but does not make an entry in that array
-        if (is_array($_SESSION['plugins']['filesystem_attachments'])) {
+      if (!empty($_SESSION['plugins']) && is_array($_SESSION['plugins']['filesystem_attachments'])) {
             foreach ($_SESSION['plugins']['filesystem_attachments'] as $group => $files) {
                 if ($args['group'] && $args['group'] != $group) {
                     continue;
--- a/plugins/jqueryui/jqueryui.php	Wed Oct 08 09:33:13 2025 -0400
+++ b/plugins/jqueryui/jqueryui.php	Wed Oct 15 14:06:01 2025 -0400
@@ -36,7 +36,7 @@
         // include UI stylesheet
         $skin     = $rcmail->config->get('skin');
         $ui_map   = $rcmail->config->get('jquery_ui_skin_map', array());
-        $ui_theme = $ui_map[$skin] ?: $skin;
+        $ui_theme = ($ui_map[$skin]??null) ?: $skin;
 
         self::$ui_theme = $ui_theme;
 
--- a/plugins/libcalendaring/libcalendaring.php	Wed Oct 08 09:33:13 2025 -0400
+++ b/plugins/libcalendaring/libcalendaring.php	Wed Oct 15 14:06:01 2025 -0400
@@ -1446,12 +1446,13 @@
     public static function part_is_vcalendar($part, $message = null)
     {
         // First check if the message is "valid" (i.e. not multipart/report)
-        if ($message) {
+        if ($message && $message->mime_parts) {
             $level = explode('.', $part->mime_id);
 
             while (array_pop($level) !== null) {
-                $parent = $message->mime_parts[join('.', $level) ?: 0];
-                if ($parent->mimetype == 'multipart/report') {
+                $parent = $message->mime_parts[join('.', $level) ?: 0]??null;
+                if (!empty($parent) &&
+		    $parent->mimetype == 'multipart/report') {
                     return false;
                 }
             }
--- a/plugins/libcalendaring/libvcalendar.php	Wed Oct 08 09:33:13 2025 -0400
+++ b/plugins/libcalendaring/libvcalendar.php	Wed Oct 15 14:06:01 2025 -0400
@@ -1380,17 +1380,21 @@
 
     /*** Implement PHP 5 Iterator interface to make foreach work ***/
 
-    function current()
+    function current(): mixed
     {
         return $this->objects[$this->iteratorkey];
     }
 
-    function key()
+    function key(): mixed
     {
         return $this->iteratorkey;
     }
 
+    #[ReturnTypeWillChange]
     function next()
+    # HST: should be void per Iterator, but returns a value, and e.g.
+    # libcalendaring_recurrence uses it:
+    # 146:            while (($next = $this->next()
     {
         $this->iteratorkey++;
 
@@ -1402,12 +1406,12 @@
         return $this->valid();
     }
 
-    function rewind()
+    function rewind(): void
     {
         $this->iteratorkey = 0;
     }
 
-    function valid()
+    function valid(): bool
     {
         return !empty($this->objects[$this->iteratorkey]);
     }
--- a/plugins/managesieve/managesieve.php	Wed Oct 08 09:33:13 2025 -0400
+++ b/plugins/managesieve/managesieve.php	Wed Oct 15 14:06:01 2025 -0400
@@ -33,6 +33,7 @@
     public $task = 'mail|settings';
     private $rc;
     private $engine;
+    private $ui_initialized;
 
     function init()
     {