Search code examples
phpglob

PHP 5.3.1 glob:// exception


I'm having problems with the glob:// stream wrapper included in the PHP 5.3.0 version. I'm using the following PHP version:

PHP 5.3.1-0.dotdeb.1 with Suhosin-Patch (cli) (built: Dec 5 2009 20:08:29) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies

When I try to execute the following example from the PHP.net website:

<?php
// Loop over all *.php files in ext/spl/examples/ directory
// and print the filename and its size
$it = new DirectoryIterator("glob://*.php");
foreach($it as $f) {
    printf("%s: %.1FK\n", $f->getFilename(), $f->getSize()/1024);
}
?>

Note that I remove the folder from the original example and left only the php extension

I get a PHP error with the following message:

SplFileInfo::getSize(): stat failed for [first php file name].php

While searching at Google about this error I discover that someone had the same problem one year ago, but looks like they fixed it.

So... My question is: Anyone is using glob:// wrapper? Am I doing something wrong? Anyone with the same problem?

Note: I already know I can do the same in other different ways but I want to test the glob:// stream wrapper :)


Solution

  • I sent this bug to PHP Bugs they confirm it's a current PHP 5.3.1 bug.

    They are trying to fix it; see Bug report #51068.

    Thank you all for your answers :)