Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug#1038441: Horde uses obsolete each() function throughout its code.

77 views
Skip to first unread message

Alain Knaff

unread,
Jun 18, 2023, 6:50:04 AM6/18/23
to
Package: php-horde-imp
Version: 6.2.27-3

Hi,

Horde still uses the obsolete each() function.
https://www.php.net/manual/en/function.each.php

Example from /usr/share/horde/imp/lib/Ajax/Application/ListMessages.php,
line 438:

while (list(,$ob) = each($overview['overview'])) {
...
}

This function has been deprecated since 7.2, and has now been removed
completely in php-8.2 (as shipped by Debian 12).

Which means that horde is basically unusable right now.

What makes this hard to debug is that most instances of it only leave a
mysterious "Error when communication with the server" error. Some
occurrences fortunately then leave additional details in
/var/log/horde.log . Others however have *only* the "Error when
communication with the server" without any further details elsewhere.

N.B. The problem occurs right after log in, when Horde / IMP attempts to
display mailbox, so is really not hard to reproduce!

Thanks for addressing this,

Alain

Michael Schlueter

unread,
Jul 20, 2023, 3:21:34 PM7/20/23
to

Ondrej Zary

unread,
Jul 28, 2023, 9:40:04 AM7/28/23
to
Package: php-horde-imp
Version: 6.2.27-3
Severity: grave
Tags: upstream
Justification: renders package unusable
Followup-For: Bug #1038441
X-Debbugs-Cc: za...@gsystem.sk

Dear Maintainer,
the bug severity should be grave as Horde IMP web UI does not work at all.

Quick fix below, but there are more bugs - e.g. when clicking on "new message" in IMP.

diff -urp imp-/lib/Ajax/Application/ListMessages.php imp/lib/Ajax/Application/ListMessages.php
--- imp-/lib/Ajax/Application/ListMessages.php 2023-02-03 19:10:03.000000000 +0100
+++ imp/lib/Ajax/Application/ListMessages.php 2023-07-28 15:04:24.994178543 +0200
@@ -434,8 +434,7 @@ class IMP_Ajax_Application_ListMessages
));

/* Display message information. */
- reset($overview['overview']);
- while (list(,$ob) = each($overview['overview'])) {
+ foreach ($overview['overview'] as $ob) {
/* Get all the flag information. */
$msg = array(
'flag' => $flags
diff -urp imp-/lib/Basic/Mailbox.php imp/lib/Basic/Mailbox.php
--- imp-/lib/Basic/Mailbox.php 2023-02-03 19:10:03.000000000 +0100
+++ imp/lib/Basic/Mailbox.php 2023-07-28 14:55:46.286208770 +0200
@@ -843,7 +843,7 @@ class IMP_Basic_Mailbox extends IMP_Basi
$search_view = clone $view;
$summary_view = clone $view;

- while (list(,$ob) = each($mbox_info['overview'])) {
+ foreach ($mbox_info['overview'] as $ob) {
if ($search_mbox) {
if (empty($lastMbox) || ($ob['mailbox'] != $lastMbox)) {
if (!empty($lastMbox)) {
diff -urp imp-/lib/Contents.php imp/lib/Contents.php
--- imp-/lib/Contents.php 2023-02-03 19:10:03.000000000 +0100
+++ imp/lib/Contents.php 2023-07-28 15:13:17.486162022 +0200
@@ -1480,8 +1480,7 @@ class IMP_Contents
continue;
}

- reset($render_part);
- while (list($id, $info) = each($render_part)) {
+ foreach ($render_part as $id => $info) {
$display_ids[$id] = 1;

if (empty($info)) {
@@ -1534,8 +1533,7 @@ class IMP_Contents
uksort($msgtext, 'strnatcmp');
}

- reset($msgtext);
- while (list($id, $part) = each($msgtext)) {
+ foreach ($msgtext as $id => $part) {
while (!empty($wrap_ids) &&
!Horde_Mime::isChild(end($wrap_ids), $id)) {
array_pop($wrap_ids);
diff -urp imp-/lib/Mime/Viewer/Plain.php imp/lib/Mime/Viewer/Plain.php
--- imp-/lib/Mime/Viewer/Plain.php 2023-02-03 19:10:03.000000000 +0100
+++ imp/lib/Mime/Viewer/Plain.php 2023-07-28 15:02:40.726183385 +0200
@@ -277,8 +277,7 @@ class IMP_Mime_Viewer_Plain extends Hord
$text_part->setContents(preg_replace("/begin [0-7]{3} .+\r?\n.+\r?\nend/Us", "\n", $text));
$new_part->addPart($text_part);

- reset($files);
- while (list(,$file) = each($files)) {
+ foreach ($files as $file) {
$uupart = new Horde_Mime_Part();
$uupart->setType('application/octet-stream');
$uupart->setContents($file['data']);
diff -urp imp-/lib/Minimal/Mailbox.php imp/lib/Minimal/Mailbox.php
--- imp-/lib/Minimal/Mailbox.php 2023-02-03 19:10:03.000000000 +0100
+++ imp/lib/Minimal/Mailbox.php 2023-07-28 14:54:34.266214279 +0200
@@ -123,7 +123,7 @@ class IMP_Minimal_Mailbox extends IMP_Mi
$mbox_info = $imp_mailbox->getMailboxArray(range($pageOb['begin'], $pageOb['end']), array('headers' => true));
$msgs = array();

- while (list(,$ob) = each($mbox_info['overview'])) {
+ foreach ($mbox_info['overview'] as $ob) {
/* Initialize the header fields. */
$msg = array(
'buid' => $imp_mailbox->getBuid($ob['mailbox'], $ob['uid']),
diff -urp kronolith-/lib/FreeBusy/View.php kronolith/lib/FreeBusy/View.php
--- kronolith-/lib/FreeBusy/View.php 2023-01-03 07:33:57.000000000 +0100
+++ kronolith/lib/FreeBusy/View.php 2023-07-28 15:22:13.650136020 +0200
@@ -305,9 +305,7 @@ abstract class Kronolith_FreeBusy_View
$template = $GLOBALS['injector']->createInstance('Horde_Template');
$template->set('label', $label);

- reset($periods);
- list($periodStart, $periodEnd) = each($periods);
-
+ foreach ($periods as $periodStart => $periodEnd) {
$blocks = '';
foreach ($this->_timeBlocks as $span) {
/* Horde_Icalendar_Vfreebusy only supports timestamps at the
@@ -343,6 +341,7 @@ abstract class Kronolith_FreeBusy_View
$blocks .= $template->fetch(KRONOLITH_TEMPLATES . '/fbview/emptyblock.html');
}
}
+ }

return $blocks;
}


-- System Information:
Debian Release: 12.1
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'oldoldstable-updates'), (500, 'oldoldstable'), (500, 'stable'), (100, 'bookworm-fasttrack'), (100, 'bookworm-backports-staging')
Architecture: amd64 (x86_64)

Kernel: Linux 5.10.0-23-amd64 (SMP w/2 CPU threads)
Locale: LANG=en_US.UTF-8, LC_CTYPE=sk_SK.UTF-8 (charmap=UTF-8), LANGUAGE=en_US:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages php-horde-imp depends on:
ii libapache2-mod-php8.2 [php-json] 8.2.7-1~deb12u1
pn php-cli <none>
ii php-common 2:93
ii php-horde 5.2.23+debian0-6
ii php-horde-auth 2.2.2-10
ii php-horde-browser 2.0.16-5
ii php-horde-cache 2.5.5-11
ii php-horde-compress 2.2.4-3
ii php-horde-core 2.31.18+debian0-2
ii php-horde-crypt 2.7.12-9
ii php-horde-css-parser 1.0.11-8
ii php-horde-date 2.4.1-9
ii php-horde-editor 2.0.5+debian0-5
ii php-horde-exception 2.0.8-10
ii php-horde-icalendar 2.1.8-7
ii php-horde-image 2.6.1-2
ii php-horde-imap-client 2.30.6-3
ii php-horde-itip 2.1.2-9
ii php-horde-listheaders 1.2.5-7
ii php-horde-logintasks 2.0.8-1
ii php-horde-mail 2.6.6-5
ii php-horde-mail-autoconfig 1.0.3-10
ii php-horde-mime 2.11.2-2
ii php-horde-mime-viewer 2.2.4+debian0-2
ii php-horde-nls 2.2.1-6
ii php-horde-notification 2.0.4-10
ii php-horde-pack 1.0.7-7
ii php-horde-perms 2.1.8-5
ii php-horde-spellchecker 2.1.3-9
ii php-horde-stream 1.6.3-10
ii php-horde-stream-filter 2.0.5-1
ii php-horde-stream-wrapper 2.1.5-1
ii php-horde-support 2.2.2-2
ii php-horde-text-filter 2.3.7-1
ii php-horde-text-flowed 2.0.4-3
ii php-horde-tree 2.0.5-6
ii php-horde-url 2.2.6-9
ii php-horde-util 2.5.12-2
ii php-horde-vfs 2.4.2-1
ii php-horde-view 2.0.6-10
ii php-xml 2:8.2+93
ii php8.2-cli [php-json] 8.2.7-1~deb12u1
ii php8.2-xml [php-xml] 8.2.7-1~deb12u1

Versions of packages php-horde-imp recommends:
ii php-horde-history 2.3.6-11
ii php-horde-http 2.1.7-11
pn php-horde-service-gravatar <none>
pn php-phpseclib-file-asn1 <none>

php-horde-imp suggests no packages.

-- no debconf information

-- debsums errors found:
debsums: changed file /usr/share/horde/imp/lib/Ajax/Application/ListMessages.php (from php-horde-imp package)
debsums: changed file /usr/share/horde/imp/lib/Basic/Mailbox.php (from php-horde-imp package)
debsums: changed file /usr/share/horde/imp/lib/Contents.php (from php-horde-imp package)
debsums: changed file /usr/share/horde/imp/lib/Mime/Viewer/Plain.php (from php-horde-imp package)
debsums: changed file /usr/share/horde/imp/lib/Minimal/Mailbox.php (from php-horde-imp package)
0 new messages