php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36134 no Exception throwed out when pass "" to DirectoryIterator construct
Submitted: 2006-01-23 10:15 UTC Modified: 2006-01-23 16:24 UTC
From: quick_defect at yahoo dot com Assigned: helly (profile)
Status: Closed Package: SPL related
PHP Version: 5.1.2 OS: redhat
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: quick_defect at yahoo dot com
New email:
PHP Version: OS:

 

 [2006-01-23 10:15 UTC] quick_defect at yahoo dot com
Description:
------------
when I use DirectoryIterator::__construct to get a new DirectoryIterator, I found it do not throw exception when "" and NULL passed as argument.

Reproduce code:
---------------
<?php
$max=mt_getrandmax();
$ar=array(1,2,3);
$ite=new RecursiveArrayIterator($ar);

$invalid=array("",new Exception,array(),$ite,$max+1,NULL,"/no/such/dir");

foreach($invalid as $p)
{
        try
        {
                $ak=new DirectoryIterator($p);
                var_dump($ak->valid());
                var_dump($ak->getPathname());
                echo "I will never come out\n";
        }catch(Exception $e)
        {
                echo "exception caught with parameter $p\n";
        }
}
?>


Expected result:
----------------
exception caught with parameter ""
exception caught with parameter Object id #2
exception caught with parameter Array
exception caught with parameter Object id #1
exception caught with parameter 2147483648
exception caught with parameter NULL
exception caught with parameter /no/such/dir


Actual result:
--------------
bool(false)
bool(false)
I will never come out
exception caught with parameter Object id #2
exception caught with parameter Array
exception caught with parameter Object id #1
exception caught with parameter 2147483648
bool(false)
bool(false)
I will never come out
exception caught with parameter /no/such/dir


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-23 15:26 UTC] sniper@php.net
Assigned to the maintainer.
 [2006-01-23 16:24 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 12 21:01:28 2024 UTC