From: flip101 at gmail dot com
Operating system: Windows
PHP version: 5.6.16
Package: Filesystem function related
Bug Type: Bug
Bug description:file_exists and is_readable fail silently
Description:
------------
file_exists and is_readable return false on windows when file exist but
full path is longer than 258 characters. This seems related to MAX_PATH
https://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx#maxpath
The best expected result would be just return true (see box expected
result), then these functions should use the unicode version of the
windows API.
In case it's not desirable to use the unicode version of the windows
API. Then the expected result would be generate PHP Warning. Now it just
return a wrong result without notification.
Test script:
---------------
<?php
$foo =
'D:\\dev\\http\\tproj\\app\\cache\\dev_old\\annotations\\72\\5b53796d666f6e795c42756e646c655c5477696742756e646c655c436f6e74726f6c6c65725c457863657074696f6e436f6e74726f6c6c657223676574416e64436c65616e4f7574707574427566666572696e67405b416e6e6f745d5d5b.doctrinecache.data';
$bar =
'D:\\dev\\http\\tproj\\app\\cache\\dev_old\\annotations\\72\\5b53796d666f6e795c42756e646c655c5477696742756e646c655c436f6e74726f6c6c65725c457863657074696f6e436f6e74726f6c6c657223676574416e64436c65616e4f7574707574427566666572696e67405b416e6e6f745d5d5b315d.doctrinecache.data';
$foo_obj = new \SplFileInfo($foo);
$bar_obj = new \SplFileInfo($bar);
var_dump($foo, file_exists($foo), file_exists($foo_obj));
var_dump($bar, file_exists($bar), file_exists($bar_obj));
Expected result:
----------------
D:\dev\http\tproj>php del.php
string(258)
"D:\dev\http\tproj\app\cache\dev_old\annotations\72\5b53796d666f6e795c42756e646c655c5477696742756e646c655c436f6e74726f6c6c65725c457863657074696f6e43
6f6e74726f6c6c657223676574416e64436c65616e4f7574707574427566666572696e67405b416e6e6f745d5d5b.doctrinecache.data"
bool(true)
bool(true)
string(262)
"D:\dev\http\tproj\app\cache\dev_old\annotations\72\5b53796d666f6e795c42756e646c655c5477696742756e646c655c436f6e74726f6c6c65725c457863657074696f6e43
6f6e74726f6c6c657223676574416e64436c65616e4f7574707574427566666572696e67405b416e6e6f745d5d5b315d.doctrinecache.data"
bool(true)
bool(true)
D:\dev\http\tproj>dir
D:\dev\http\tproj\app\cache\dev_old\annotations\72\
Volume in drive D is Data
Volume Serial Number is 2E83-BAB4
Directory of D:\dev\http\tproj\app\cache\dev_old\annotations\72
01-12-2015 15:09 <DIR> .
01-12-2015 15:09 <DIR> ..
01-12-2015 15:04 9
5b53796d666f6e795c42756e646c655c5477696742756e646c655c436f6e74726f6c6c65725c457863657074696f6e436f6e74726f6c6c65722367657441
6e64436c65616e4f7574707574427566666572696e67405b416e6e6f745d5d5b.doctrinecache.data
01-12-2015 15:01 9
5b53796d666f6e795c42756e646c655c5477696742756e646c655c436f6e74726f6c6c65725c457863657074696f6e436f6e74726f6c6c65722367657441
6e64436c65616e4f7574707574427566666572696e67405b416e6e6f745d5d5b315d.doctrinecache.data
2 File(s) 18 bytes
2 Dir(s) 7.241.150.464 bytes free
Actual result:
--------------
D:\dev\http\tproj>php del.php
string(258)
"D:\dev\http\tproj\app\cache\dev_old\annotations\72\5b53796d666f6e795c42756e646c655c5477696742756e646c655c436f6e74726f6c6c65725c457863657074696f6e43
6f6e74726f6c6c657223676574416e64436c65616e4f7574707574427566666572696e67405b416e6e6f745d5d5b.doctrinecache.data"
bool(true)
bool(true)
string(262)
"D:\dev\http\tproj\app\cache\dev_old\annotations\72\5b53796d666f6e795c42756e646c655c5477696742756e646c655c436f6e74726f6c6c65725c457863657074696f6e43
6f6e74726f6c6c657223676574416e64436c65616e4f7574707574427566666572696e67405b416e6e6f745d5d5b315d.doctrinecache.data"
bool(false)
bool(false)
D:\dev\http\tproj>dir
D:\dev\http\tproj\app\cache\dev_old\annotations\72\
Volume in drive D is Data
Volume Serial Number is 2E83-BAB4
Directory of D:\dev\http\tproj\app\cache\dev_old\annotations\72
01-12-2015 15:09 <DIR> .
01-12-2015 15:09 <DIR> ..
01-12-2015 15:04 9
5b53796d666f6e795c42756e646c655c5477696742756e646c655c436f6e74726f6c6c65725c457863657074696f6e436f6e74726f6c6c65722367657441
6e64436c65616e4f7574707574427566666572696e67405b416e6e6f745d5d5b.doctrinecache.data
01-12-2015 15:01 9
5b53796d666f6e795c42756e646c655c5477696742756e646c655c436f6e74726f6c6c65725c457863657074696f6e436f6e74726f6c6c65722367657441
6e64436c65616e4f7574707574427566666572696e67405b416e6e6f745d5d5b315d.doctrinecache.data
2 File(s) 18 bytes
2 Dir(s) 7.241.150.464 bytes free
--
Edit bug report at https://bugs.php.net/bug.php?id=71103&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71103&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71103&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71103&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=71103&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=71103&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=71103&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=71103&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=71103&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=71103&r=support
Expected behavior: https://bugs.php.net/fix.php?id=71103&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=71103&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=71103&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=71103&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71103&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=71103&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=71103&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=71103&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71103&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=71103&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=71103&r=mysqlcfg