[php-maint] Bug#312890: marked as done (php4: foreach() doesn't issue an error when a variable other than of the type 'array' is passed to it)

Debian Bug Tracking System owner at bugs.debian.org
Sat Aug 13 10:03:16 UTC 2005


Your message dated Sat, 13 Aug 2005 11:47:12 +0200
with message-id <1123926432.12147.15.camel at maple.active24.cz>
and subject line Fixed in php4 4.4.0
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--------------------------------------
Received: (at submit) by bugs.debian.org; 10 Jun 2005 16:02:15 +0000
>From macristo at gmx.net Fri Jun 10 09:02:15 2005
Return-path: <macristo at gmx.net>
Received: from smtp-vbr13.xs4all.nl [194.109.24.33] 
	by spohr.debian.org with esmtp (Exim 3.35 1 (Debian))
	id 1DglxX-00020A-00; Fri, 10 Jun 2005 09:02:15 -0700
Received: from [192.168.1.110] (entercom.xs4all.nl [194.109.161.232])
	by smtp-vbr13.xs4all.nl (8.13.3/8.13.3) with ESMTP id j5AG2EUQ022916;
	Fri, 10 Jun 2005 18:02:14 +0200 (CEST)
	(envelope-from macristo at gmx.net)
Message-Id: <200506101602.j5AG2EUQ022916 at smtp-vbr13.xs4all.nl>
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
From: Patrick Nijs <macristo at gmx.net>
To: Debian Bug Tracking System <submit at bugs.debian.org>
Subject: php4: foreach() doesn't issue an error when a variable other than of the
 type 'array' is passed to it
X-Mailer: reportbug 3.8
Date: Fri, 10 Jun 2005 18:08:55 +0200
X-Virus-Scanned: by XS4ALL Virus Scanner
Delivered-To: submit at bugs.debian.org
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2005_01_02 
	(1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Status: No, hits=-6.5 required=4.0 tests=BAYES_00,HAS_PACKAGE,
	HTML_MESSAGE autolearn=no version=2.60-bugs.debian.org_2005_01_02
X-Spam-Level: 

Package: php4
Version: 4:4.3.10-15
Severity: minor

From: http://nl3.php.net/foreach:

"(...) foreach works only on arrays, and will issue an error when you
try to use it on a variable with a different data type or an
uninitialized variable. (...)"

Well, on my Debian-testing server, PHP does not issue a warning when I
pass a var to foreach which isn't an array.

For example the following code will not output a warning with
error_reporting(EALL):

$res = NULL;

foreach ($res as $key => $value) {
	echo $key . "<br />";
}

It DOES generate a warning on my W32-machine with PHP 4.3.11 installed.

To circumvent the warning on W32 I have to write the following code:

$res = NULL;

if (!is_null($res)) {
	foreach ($res as $key => $value) {
		echo $key . "<br />";
	}
}

And this should be done on Debian too.

Regards,

Patrick




-- System Information:
Debian Release: 3.1
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.4.27-2-386
Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ISO-8859-1)

Versions of packages php4 depends on:
ii  libapache-mod-php4           4:4.3.10-15 server-side, HTML-embedded scripti
ii  php4-common                  4:4.3.10-15 Common files for packages built fr

-- no debconf information

---------------------------------------
Received: (at 312890-done) by bugs.debian.org; 13 Aug 2005 09:47:01 +0000
>From ondrej at sury.org Sat Aug 13 02:47:01 2005
Return-path: <ondrej at sury.org>
Received: from mail.active24.cz [81.95.104.4] 
	by spohr.debian.org with esmtp (Exim 3.36 1 (Debian))
	id 1E3sbV-0008Pt-00; Sat, 13 Aug 2005 02:47:01 -0700
Received: from [192.168.1.2] (r4v190.chello.upc.cz [84.42.149.190])
	by mail.active24.cz (Postfix) with ESMTP id BD93028000AF
	for <312890-done at bugs.debian.org>; Sat, 13 Aug 2005 11:50:24 +0200 (CEST)
Subject: Fixed in php4 4.4.0
From: Ondrej Sury <ondrej at sury.org>
To: 312890-done at bugs.debian.org
Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-CSQB+wlps1jLCOgkfYp5"
Date: Sat, 13 Aug 2005 11:47:12 +0200
Message-Id: <1123926432.12147.15.camel at maple.active24.cz>
Mime-Version: 1.0
X-Mailer: Evolution 2.3.7 
Delivered-To: 312890-done at bugs.debian.org
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2005_01_02 
	(1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Level: 
X-Spam-Status: No, hits=-1.5 required=4.0 tests=BAYES_00,HTML_MESSAGE 
	autolearn=no version=2.60-bugs.debian.org_2005_01_02


--=-CSQB+wlps1jLCOgkfYp5
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

Hi,

I believe your bug was fixed in php4 4.4.0-1 and higher:

root at maple:/tmp# dpkg -l php4-cli
Desired=3DUnknown/Install/Remove/Purge/Hold
| Status=3DNot/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=3D(none)/Hold/Reinst-required/X=3Dboth-problems (Status,Err: upperc=
ase=3Dbad)
||/ Name                              Version                           Des=
cription
+++-=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D-=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D-=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D
ii  php4-cli                          4.4.0-1                           com=
mand-line interpreter for the php4 scripting language
root at maple:/tmp# cat foreach.php
<?php
error_reporting(E_ALL);

$res =3D NULL;

foreach ($res as $key =3D> $value) {
    echo $key . "<br />";
}

?>
root at maple:/tmp# php4 foreach.php

Warning: Invalid argument supplied for foreach() in /tmp/foreach.php on lin=
e 6

Ondrej.
--=20
Ondrej Sury <ondrej at sury.org>

--=-CSQB+wlps1jLCOgkfYp5
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQBC/cGg9OZqfMIN8nMRAqdsAJ0Sa3x0ty9JkUFiQd5EaDTWKiTAXACfZx+/
QRinZmM0dwTmAFRMki13E58=
=2E9c
-----END PGP SIGNATURE-----

--=-CSQB+wlps1jLCOgkfYp5--




More information about the pkg-php-maint mailing list