Bug #75210 [NEW]: GlobIterator on current directory uses invalid path for SplFileInfo
| From: | php at pointpro dot nl | Date: | Fri, 15 Sep 2017 10:48:53 +0000 |
| Subject: | Bug #75210 [NEW]: GlobIterator on current directory uses invalid path for SplFileInfo | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-211173@lists.php.net to get a copy of this message | ||
From: php at pointpro dot nl
Operating system: Ubuntu 16.04
PHP version: 7.1.9
Package: Directory function related
Bug Type: Bug
Bug description:GlobIterator on current directory uses invalid path for SplFileInfo
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 bug report at https://bugs.php.net/bug.php?id=75210&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75210&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75210&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75210&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75210&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75210&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75210&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75210&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75210&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75210&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75210&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75210&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75210&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75210&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75210&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75210&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75210&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75210&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75210&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75210&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75210&r=mysqlcfg