Edit report at http://bugs.php.net/bug.php?id=54384&edit=1

 ID:                 54384
 Updated by:         cataphr...@php.net
 Reported by:        lbarn...@php.net
 Summary:            Several SPL classes crash when parent constructor is
                     not called
-Status:             Assigned
+Status:             Closed
 Type:               Bug
 Package:            SPL related
 PHP Version:        trunk-SVN-2011-03-25 (SVN)
 Assigned To:        cataphract
 Block user comment: N
 Private report:     N

 New Comment:

Commited (different) fix in 5.3.


Previous Comments:
------------------------------------------------------------------------
[2011-04-04 04:50:30] cataphr...@php.net

Automatic comment from SVN on behalf of cataphract
Revision: http://svn.php.net/viewvc/?view=revision&revision=309929
Log: - Fixed bug #54384 (Dual iterators, GlobIterator, SplFileObject and
  SplTempFileObject crash when user-space classes don't call the paren
  constructor).

------------------------------------------------------------------------
[2011-03-28 00:44:36] cataphr...@php.net

Automatic comment from SVN on behalf of cataphract
Revision: http://svn.php.net/viewvc/?view=revision&revision=309751
Log: - Improved upon r309729.
- Extented strategy to remaining the classes on spl_directory.c, even
those that don't crash.
- UPGRADING.
- Better bug54384.phpt, with all the classes covered.

------------------------------------------------------------------------
[2011-03-27 06:21:09] cataphr...@php.net

Automatic comment from SVN on behalf of cataphract
Revision: http://svn.php.net/viewvc/?view=revision&revision=309729
Log: - Fixed bug #54384: Several SPL classes crash when parent
constructor is
  not called.
#Merge to 5.3 pending (slight BC break on AppendIterator, as it's no
#longer possible to defer the call to the parent constructor until
#after the constructor is performed).
#Bugs fixed in an atypical way for SPL. The parent constructor call
#check is performed at construction time by using a wrapper constructor
#instead of a check on the beginning of each instance method.
#Perhaps this should be uniformized in trunk; this method was mainly
#applied only to the ones crashing, except a few iterators (at least
#AppendIterator and RecursiveIteratorIterator).

------------------------------------------------------------------------
[2011-03-25 22:32:11] lbarn...@php.net

I wondered if other classes are be affected by this, and after some

tests I found that the following classes are affected:



IteratorIterator

FilterIterator

RecursiveFilterIterator

ParentIterator

LimitIterator

CachingIterator

RecursiveCachingIterator

NoRewindIterator

InfiniteIterator

RegexIterator

RecursiveRegexIterator

GlobIterator

SplFileObject

SplTempFileObject



tests:



<?php



class IteratorIteratorTest extends IteratorIterator {

    function __construct(){}

}

$o = new IteratorIteratorTest;

$o->rewind()



class FilterIteratorTest extends FilterIterator {

    function __construct(){}

    function accept(){}

}

$o = new FilterIteratorTest;

$o->rewind()



class RecursiveFilterIteratorTest extends RecursiveFilterIterator {

    function __construct(){}

    function accept(){}

}

$o = new RecursiveFilterIteratorTest;

$o->hasChildren()



class ParentIteratorTest extends ParentIterator {

    function __construct(){}

}

$o = new ParentIteratorTest;

$o->accept()



class LimitIteratorTest extends LimitIterator {

    function __construct(){}

}

$o = new LimitIteratorTest;

$o->rewind()



class CachingIteratorTest extends CachingIterator {

    function __construct(){}

}

$o = new CachingIteratorTest;

$o->rewind()



class RecursiveCachingIteratorTest extends RecursiveCachingIterator {

    function __construct(){}

}

$o = new RecursiveCachingIteratorTest;

$o->rewind()



class NoRewindIteratorTest extends NoRewindIterator {

    function __construct(){}

}

$o = new NoRewindIteratorTest;

$o->valid()



class InfiniteIteratorTest extends InfiniteIterator {

    function __construct(){}

}

$o = new InfiniteIteratorTest;

$o->next()



class RegexIteratorTest extends RegexIterator {

    function __construct(){}

}

$o = new RegexIteratorTest;

$o->rewind()



class RecursiveRegexIteratorTest extends RecursiveRegexIterator {

    function __construct(){}

}

$o = new RecursiveRegexIteratorTest;

$o->hasChildren()



class GlobIteratorTest extends GlobIterator {

    function __construct(){}

}

$o = new GlobIteratorTest;

$o->count()



class SplFileObjectTest extends SplFileObject {

    function __construct(){}

}

$o = new SplFileObjectTest;

$o->rewind()



class SplTempFileObjectTest extends SplTempFileObject {

    function __construct(){}

}

$o = new SplTempFileObjectTest;

$o->rewind()

------------------------------------------------------------------------
[2011-03-25 21:34:56] lbarn...@php.net

Description:
------------
FilterIterator instances crash when the constructor has not been called


(accidentally).





Test script:
---------------
<?php



class Test extends FilterIterator {

    function __construct() {

    }

    function accept() {

    }

}



$t = new Test;

foreach($t as $e);



------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=54384&edit=1

Reply via email to