Bug #71103 [Asn->Csd]: file_exists and is_readable fail silently

From: Date: Mon, 08 Aug 2016 10:10:25 +0000
Subject: Bug #71103 [Asn->Csd]: file_exists and is_readable fail silently
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-203072@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71103&edit=1 ID: 71103 Updated by: ab@php.net Reported by: flip101 at gmail dot com Summary: file_exists and is_readable fail silently -Status: Assigned +Status: Closed Type: Bug Package: Filesystem function related Operating System: Windows PHP Version: 5.6.16 Assigned To: ab Block user comment: N Private report: N New Comment: Fixed in PHP 7.1, please read UPGRADING. Thanks. Previous Comments: ------------------------------------------------------------------------ [2015-12-12 16:21:18] flip101 at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=71103&edit=1

« previous php.bugs (#203072) next »