Bug #76877 [Opn->Fbk]: file_exists() don't see hosts file

From: Date: Thu, 13 Sep 2018 17:09:58 +0000
Subject: Bug #76877 [Opn->Fbk]: file_exists() don't see hosts file
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217035@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 Updated by: ab@php.net Reported by: dominique at ottello dot net Summary: file_exists() don't see hosts file -Status: Open +Status: Feedback Type: Bug Package: *General Issues Operating System: Windows 7 64bit PHP Version: 7.3.0RC1 Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#217035) next »