Bug #65867 [Opn]: Countable interface infinite recursion.
| From: | kakserpompoyaitsam at gmail dot com | Date: | Wed, 09 Oct 2013 04:46:21 +0000 |
| Subject: | Bug #65867 [Opn]: Countable interface infinite recursion. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-182095@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65867&edit=1
ID: 65867
User updated by: kakserpompoyaitsam at gmail dot com
Reported by: kakserpompoyaitsam at gmail dot com
-Summary: strace php -r 'class A implements Countable
{function count() {return count($th
+Summary: Countable interface infinite recursion.
Status: Open
Type: Bug
Package: SPL related
Operating System: Irrelevant
PHP Version: 5.5.4
Block user comment: N
Private report: N
New Comment:
Changed title.
Previous Comments:
------------------------------------------------------------------------
[2013-10-09 04:44:30] kakserpompoyaitsam at gmail dot com
Description:
------------
Easy reproducible segmentation fault.
It seems that count($this) doesn't check recursion. I think that count($this) should check if
it is called inside of $this->count(), and if so, should ignore the Countable interface and just
count the properties. Use case: if your object got special properties that you do not want to count,
you can use something liek that: "function count() {return count($this) -
numberOfSpecialProperties;}"
Test script:
---------------
class A implements Countable {function count() {return count($this);}} count(new A);
Expected result:
----------------
0
Actual result:
--------------
Segmentation fault.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65867&edit=1