Doc #63406 [Opn->Csd]: Count *does* detect infinite recursion
| From: | salathe@php.net | Date: | Mon, 12 Nov 2012 22:42:28 +0000 |
| Subject: | Doc #63406 [Opn->Csd]: Count *does* detect infinite recursion | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-9106@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63406&edit=1
ID: 63406
Updated by: salathe@php.net
Reported by: n at p12a dot org dot uk
Summary: Count *does* detect infinite recursion
-Status: Open
+Status: Closed
Type: Documentation Problem
Package: Documentation problem
PHP Version: master-Git-2012-10-31 (Git)
-Assigned To:
+Assigned To: salathe
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation better.
Committed requinix's patch.
Previous Comments:
------------------------------------------------------------------------
[2012-11-12 22:33:45] salathe@php.net
Automatic comment from SVN on behalf of salathe
Revision: http://svn.php.net/viewvc/?view=revision&revision=328332
Log: count() does in fact discover recursion and issues an E_WARNING in response... but it will
probably return a much higher number than it should. (doc #63406)
--
Provided by anonymous #22227 (mail+php@requinix.net)
------------------------------------------------------------------------
[2012-11-03 01:07:18] mail+php at requinix dot net
...and the number may be wildly inaccurate. Sounds like a bug: counts first and
stops recursion second?
$a = array(1, 2, 3);
$a[] =& $a;
$a[] =& $a;
$a[] =& $a;
echo count($a, COUNT_RECURSIVE); // 78
Did you know you can easily submit changes to the online documentation? Look for
the [edit] in the top-right corner of manual pages.
I've submitted some changes for you:
"count: detects recursion (bug #63406)"
http://edit.php.net/?patchID=761&project=PHP
------------------------------------------------------------------------
[2012-10-31 19:37:23] n at p12a dot org dot uk
Description:
------------
---
From manual page: http://www.php.net/function.count#refsect1-function.count-
parameters
---
The manual says "count() does not detect infinite recursion". But count() does.
Test script:
---------------
$a = array();
$a[] = &$a;
echo count($a, 1), "\n"
Expected result:
----------------
Most probably an out-of-memory error, which is what I get when infinitely
recursing in a user-defined function.
Actual result:
--------------
PHP Warning: count(): recursion detected in Command line code on line 1
3
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63406&edit=1