Bug #75210 [Com]: GlobIterator on current directory uses invalid path for SplFileInfo

From: Date: Fri, 15 Sep 2017 11:43:55 +0000
Subject: Bug #75210 [Com]: GlobIterator on current directory uses invalid path for SplFileInfo
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-211174@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75210&edit=1 ID: 75210 Comment by: sjon at hortensius dot net Reported by: php at pointpro dot nl Summary: GlobIterator on current directory uses invalid path for SplFileInfo Status: Open Type: Bug Package: Directory function related Operating System: Ubuntu 16.04 PHP Version: 7.1.9 Block user comment: N Private report: N New Comment: Can confirm, see https://3v4l.org/aUqLF Previous Comments: ------------------------------------------------------------------------ [2017-09-15 10:48:48] php at pointpro dot nl Description: ------------ When using the GlobIterator for the current directory, results depend on the notation. When using, for example, *.php, the resulting SplFileInfo objects will be invalid, while if you use './*.php' they will be valid. Observe the difference in output with the test script. I ran it in a directory containing the script itself as test.php and two other files called test2.php and test3.php It seems that that the GlobIterator adds a '/' at the beginning of the path when I specify no path information, which makes SplFileInfo resolve it as a file in the file system root, which is not correct. I'm tried this using 7.1.9-1+ubuntu16.04.1+deb.sury.org+1 from http://ppa.launchpad.net/ondrej/php/ubuntu and the same also occurs in 7.0.23-1+ubuntu16.04.1+deb.sury.org+1 from that same repository. Test script: --------------- $it = new GlobIterator("./*.php"); foreach ($it as $p) { echo $p->getFilename() . " " . ($p->isFile() ? "IS" : "IS NOT") . " a file\n"; } $it = new GlobIterator("*.php"); foreach ($it as $p) { echo $p->getFilename() . " " . ($p->isFile() ? "IS" : "IS NOT") . " a file\n"; } Expected result: ---------------- ./test.php IS a file ./test2.php IS a file ./test3.php IS a file test.php IS a file test2.php IS a file test3.php IS a file Actual result: -------------- test.php IS a file test2.php IS a file test3.php IS a file /test.php IS NOT a file /test2.php IS NOT a file /test3.php IS NOT a file ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75210&edit=1

« previous php.bugs (#211174) next »