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: 2018-08-18 11:27 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: cmb (profile)
Status: Duplicate Package: SPL related
PHP Version: 5.3.2 OS: Linux
Private report: No CVE-ID: None
 [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

Pull Requests

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
 [2018-08-18 11:27 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2018-08-18 11:27 UTC] cmb@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

This is a duplicate of bug #51068 (actually it is the other way
round, but since the other ticket contains more useful comments,
I'm marking this as dupe).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC