Edit report at https://bugs.php.net/bug.php?id=78939&edit=1
ID: 78939
Comment by: michael dot vorisek at email dot cz
Reported by: michael dot vorisek at email dot cz
Summary: file_exists produces different results with TS and
NTS builds
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:
Yes, if relative path with drive letter should be supported, PHP must process it the same way it
resolves standard relative paths like '../x.txt' and support php.ini directived like
include_path.
Or simply remove the support for it and display PHP warning, as the format is very confusing, not
supported even by explorer.exe (but other relative formats are) and a lot of people are not aware of
it.
Previous Comments:
------------------------------------------------------------------------
[2019-12-10 11:38:25] requinix@php.net
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.
------------------------------------------------------------------------
[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