Bug #76877 [Fbk->Opn]: file_exists() don't see hosts file
| From: | dominique at ottello dot net | Date: | Fri, 14 Sep 2018 11:32:00 +0000 |
| Subject: | Bug #76877 [Fbk->Opn]: file_exists() don't see hosts file | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-217044@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76877&edit=1
ID: 76877
User updated by: dominique at ottello dot net
Reported by: dominique at ottello dot net
Summary: file_exists() don't see hosts file
-Status: Feedback
+Status: Open
Type: Bug
Package: *General Issues
Operating System: Windows 7 64bit
-PHP Version: 7.3.0RC1
+PHP Version: 7.3.0RC1 32bit
Block user comment: N
Private report: N
New Comment:
Hi,
Last night, I spent more than four hours doing a lot of testing, checking access rights to the
folders and files involved without finding anything conclusive. Always the error "file not
exists" only with PHP 7.3.0RC1 32 bit under Windows 7 64 bit.
No problem with PHP 7.3.0RC1 64-bit under Windows 7 64-bit, nor with all versions of PHP 32 and
64-bit (PHP7.3.0RC1 including), but under Windows10.
This morning, there were updates for Windows 7 and Windows 10 and I only resumed testing after these
updates.
And, as if by a miracle, no more "file not exists" errors.
Miracles do not exist in computing, so I deduce that this update of Windows 7 64bit fixed something
that had been broken previously, perhaps by a previous update.
Sorry for all this inconvenience, but it was still extremely strange that this problem was only seen
by PHP 7.3.0 32bit and never by any other version of PHP.
So it wasn't a bug....
Previous Comments:
------------------------------------------------------------------------
[2018-09-13 17:09:58] ab@php.net
Thanks for the report. I'm not able to reproduce the behavior using the provided snippet. Even
with 1000 runs it matches the expected behavior. Some environment issue might be involved, like some
other program sharing same port, etc. Could you check that, please?
Thanks.
------------------------------------------------------------------------
[2018-09-13 13:13:08] dominique at ottello dot net
Description:
------------
PHP 7.3.0rc1 32 bit on Windows 7 64 bit
Return false for
file_exists('c:/windows/system32/drivers/etc/hosts');
or
is_writable('c:/windows/system32/drivers/etc/hosts');
although we can open this file or take its content by file() or file_get_contents() and even modify
it with fwrite().
I have never encountered this problem with any other version of PHP, including 7.2.10 32 bit.
I went back to the first version PHP 7.3.0alpha2 which has the same problem.
Test script:
---------------
$c_hostsFile =
str_replace("\\","/",getenv('WINDIR').'/system32/drivers/etc/hosts');
// Check file_exists
$i = 1;
$def = 0;
do {
clearstatcache();
if(!file_exists($c_hostsFile)) {
echo "File ".$c_hostsFile." DOES NOT EXISTS - Test number
".$i."<br>";
$def++;
}
$del = rand(100,500)*1000;
//echo "Test number ".$i." Delay ".($del/1000)." ms<br>";
usleep($del);
$i++;
} while ($i < 100 && $def < 10);
echo $i." tests<br>";
Expected result:
----------------
--- Windows NT 6.1 build 7601 (Windows 7 Professional Edition Service Pack 1) x64 64bit---
--- Serveur Apache/2.4.34 (Win32) PHP/7.3.0RC1 ---
--- PHP version 7.3.0RC1 32bit ----
100 tests
Actual result:
--------------
--- Windows NT 6.1 build 7601 (Windows 7 Professional Edition Service Pack 1) x64 64bit---
--- Serveur Apache/2.4.34 (Win32) PHP/7.3.0RC1 ---
--- PHP version 7.3.0RC1 32bit ----
File C:/Windows/system32/drivers/etc/hosts DOES NOT EXISTS - Test number 1
File C:/Windows/system32/drivers/etc/hosts DOES NOT EXISTS - Test number 2
File C:/Windows/system32/drivers/etc/hosts DOES NOT EXISTS - Test number 3
File C:/Windows/system32/drivers/etc/hosts DOES NOT EXISTS - Test number 4
File C:/Windows/system32/drivers/etc/hosts DOES NOT EXISTS - Test number 5
File C:/Windows/system32/drivers/etc/hosts DOES NOT EXISTS - Test number 6
File C:/Windows/system32/drivers/etc/hosts DOES NOT EXISTS - Test number 7
File C:/Windows/system32/drivers/etc/hosts DOES NOT EXISTS - Test number 8
File C:/Windows/system32/drivers/etc/hosts DOES NOT EXISTS - Test number 9
File C:/Windows/system32/drivers/etc/hosts DOES NOT EXISTS - Test number 10
11 tests
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76877&edit=1