Bug #78939 [Opn->Fbk]: file_exists produces different results with TS and NTS builds

From: Date: Tue, 10 Dec 2019 11:38:25 +0000
Subject: Bug #78939 [Opn->Fbk]: file_exists produces different results with TS and NTS builds
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224188@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78939&edit=1 ID: 78939 Updated by: requinix@php.net Reported by: michael dot vorisek at email dot cz Summary: file_exists produces different results with TS and NTS builds -Status: Open +Status: Feedback Type: Bug Package: *Directory/Filesystem functions Operating System: Windows PHP Version: 7.3.12 Block user comment: N Private report: N New Comment: C:x.txt is a valid path: it references x.txt in the process's current working directory on the C drive. https://docs.microsoft.com/en-us/dotnet/standard/io/file-path-formats I imagine the NTS build is inheriting the C: working directory from whatever process you used to spawn it. This would be one of those "different in more ways than just threading" aspects I mentioned in the other report. Ultimately it is a relative path, and relative paths are subject to the environment. Previous Comments: ------------------------------------------------------------------------ [2019-12-10 11:28:41] michael dot vorisek at email dot cz Description: ------------ After spending a lot of time why PHP app does work on one PC and not on another, comparing gigabytes of logs, I find very weird behaviour of core PHP file function. var_dump(file_exists('C:x.txt')); if the file "C:/x.txt" exists, PHP produces different results with TS and NTS builds on Windows if the path is without slash after "C:", i.e. - output for "C:/x.txt" is corrent and consitent across TS and NTS builds - output for "C:x.txt" differs across TS and NTS builds The path format without slash after "C:" is not supported in explorer.exe, so for me it seems that paths like "C:something" should be considered invalid and the TS build should be fixed to always return false. Note: other file functions are probably affected too. Test script: --------------- // 1. manually create any/empty file and save it under "C:/x.txt" // 2. run this code with PHP TS and PHP NTS var_dump(ZEND_THREAD_SAFE); var_dump(file_exists('C:/x.txt')); var_dump(file_exists('C:x.txt')); // 3. notice the different output of the 3rd line Expected result: ---------------- // expected output from PHP TS and NTS bool(true) OR bool(false) // dump of ZEND_THREAD_SAFE constant bool(true) bool(true) OR bool(false) // TBD, path without slash after "C:" - see desc., but output need to be consistent across TS and NTS PHP builds Actual result: -------------- // output from PHP TS bool(true) bool(true) bool(true) // output from PHP NTS bool(false) bool(true) bool(false) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78939&edit=1

« previous php.bugs (#224188) next »