ID: 51068 Updated by: ahar...@php.net Reported By: pedro dot laguna at pentura dot com Status: Assigned Bug Type: Feature/Change Request Operating System: Linux PHP Version: 5.3.1 Assigned To: colder New Comment:
OK, strike my last patch, since it was only half of the solution. This is really two bugs for the price of one. The first problem is that globs without a path (such as glob://*) always had a / prepended to their file name within spl_filesystem_object_get_file_name(), which caused the problem in this bug: that a relative foo.txt was resulting in a call to stat("/foo.txt"), which was obviously wrong. The second problem is in the glob wrapper itself. php_glob_stream_path_split() had an off-by-one error that meant that glob patterns within the root directory resulted in an empty path string, just the same as a relative glob. This was being partially masked by the first problem, since the automatic prepending meant that globbing the root directory worked more or less by accident. I've added a phpt file for the reported issue. I'm unsure of the best way to attack testing iterating over the root directory in a platform-independent manner; this may be worth someone with more familiarity writing a test for this case (ie creating a DirectoryIterator with glob:///* on platforms where it makes sense and seeing if the results look vaguely sensible). So, the patches, (hopefully) ready for review and application: Against PHP_5_3: http://www.adamharvey.name/patches/bug-51068-5.3.patch Against trunk: http://www.adamharvey.name/patches/bug-51068-trunk.patch Previous Comments: ------------------------------------------------------------------------ [2010-02-17 17:10:37] ahar...@php.net I kept looking into this after my initial post; I wasn't quite expecting this to be assigned quite so fast! A quick and dirty patch against PHP_5_3 that appears to fix this is at http://www.adamharvey.name/patches/bug-51068-spl_directory.patch -- I can cook up a .phpt to go with it pretty rapidly if desired. This also doesn't look terribly difficult to port to trunk. ------------------------------------------------------------------------ [2010-02-17 16:58:57] col...@php.net I'll look into it. Looks like glob://* makes DirectoryIterator generate paths like /file, which is wrong. ------------------------------------------------------------------------ [2010-02-17 16:57:44] pedro dot laguna at pentura dot com pe...@pedro:~$ 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 pe...@pedro:~$ apache2 -v Server version: Apache/2.2.12 (Ubuntu) Server built: Nov 12 2009 22:49:46 ------------------------------------------------------------------------ [2010-02-17 16:47:59] paj...@php.net Which SAPI do you use? (or with which web server) ------------------------------------------------------------------------ [2010-02-17 16:28:28] pedro dot laguna at pentura dot com Without the size object reference it works as expected. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/51068 -- Edit this bug report at http://bugs.php.net/?id=51068&edit=1