From 2af1148afec8623eafd4846479d36c0082e4ca61 Mon Sep 17 00:00:00 2001 From: Torben Dannhauer Date: Wed, 1 Jul 2026 12:01:36 +0200 Subject: [PATCH] fix(imp): prevent search and subscribe PHP warnings Normalize IMP_Search_Query mailbox lists to IMP_Mailbox objects before deduplicating, avoiding array_unique() keeping string entries. Ensure subscribe() always sets a success notification when the parent mailbox action succeeded but all subfolder attempts were ignored. --- lib/Mailbox.php | 4 ++++ lib/Search/Query.php | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/Mailbox.php b/lib/Mailbox.php index 1983c070c..77a3a9cae 100644 --- a/lib/Mailbox.php +++ b/lib/Mailbox.php @@ -960,6 +960,10 @@ public function subscribe($sub, array $opts = []) $notify = $sub ? sprintf(_('You were successfully subscribed to "%s" and all subfolders.'), $this->display) : sprintf(_('You were successfully unsubscribed from "%s" and all subfolders.'), $this->display); + } else { + $notify = $sub + ? sprintf(_('You were successfully subscribed to "%s".'), $this->display) + : sprintf(_('You were successfully unsubscribed from "%s".'), $this->display); } } diff --git a/lib/Search/Query.php b/lib/Search/Query.php index 7863fe0ce..f0d5dbdaa 100644 --- a/lib/Search/Query.php +++ b/lib/Search/Query.php @@ -209,7 +209,16 @@ public function __get($name) } } - $this->_cache['mboxes'] = array_unique($out, SORT_REGULAR); + $mboxes = []; + foreach ($out as $mbox) { + if (!$mbox instanceof IMP_Mailbox) { + $mbox = IMP_Mailbox::get($mbox); + } + if ($mbox) { + $mboxes[strval($mbox)] = $mbox; + } + } + $this->_cache['mboxes'] = array_values($mboxes); } return $this->_cache['mboxes'];