php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52233 DirectoryIterator glob:// fails with getSize() with using relative paths
Submitted: 2010-07-02 10:38 UTC Modified: 2010-07-02 18:56 UTC
Votes:4
Avg. Score:2.2 ± 0.8
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: pedro dot laguna at pentura dot com Assigned:
Status: Open Package: SPL related
PHP Version: 5.3.2 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-07-02 10:38 UTC] pedro dot laguna at pentura dot com
Description:
------------
glob:// wrapper doesn't support current queries like glob://*

Test script:
---------------
<?php
$it = new DirectoryIterator("glob://*");
foreach($it as $f) {
	printf("%s: %.1FK<br />", $f->getFilename(), $f->getSize()/1024);
}
?>

Expected result:
----------------
A list of files with their file size associated as show in the glob example page: 
http://php.net/manual/en/wrappers.glob.php

tree.php: 1.0K
findregex.php: 0.6K
findfile.php: 0.7K
dba_dump.php: 0.9K
nocvsdir.php: 1.1K
phar_from_dir.php: 1.0K
ini_groups.php: 0.9K
directorytree.php: 0.9K
dba_array.php: 1.1K
class_tree.php: 1.8K

Actual result:
--------------
Fatal error: Uncaught exception 'RuntimeException' with message 
'SplFileInfo::getSize(): stat failed for /CREDITS' in /home/pedro/Desktop/php-
5.3.2/sapi/cli/test.php:4
Stack trace:
#0 /home/pedro/Desktop/php-5.3.2/sapi/cli/test.php(4): SplFileInfo->getSize()
#1 {main}
  thrown in /home/pedro/Desktop/php-5.3.2/sapi/cli/test.php on line 4

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-02 18:56 UTC] felipe@php.net
-Summary: DirectoryIterator glob:// don't support current path relative queries +Summary: DirectoryIterator glob:// fails with getSize() with using relative paths -Package: Unknown/Other Function +Package: SPL related
 [2015-01-03 15:52 UTC] kassner@php.net
Reproducible on PHP 5.5.20.

[root@brian ~]# php bug.php 
bin: 20.0K<br />PHP Fatal error:  Uncaught exception 'RuntimeException' with message 'SplFileInfo::getSize(): stat failed for /bug.php' in /root/bug.php:4
Stack trace:
#0 /root/bug.php(4): SplFileInfo->getSize()
#1 {main}
  thrown in /root/bug.php on line 4
[root@brian ~]# php -v
PHP 5.5.20 (cli) (built: Dec 17 2014 14:58:05) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC