Bug #78939 [Com]: file_exists produces different results with TS and NTS builds

From: Date: Tue, 10 Dec 2019 14:28:21 +0000
Subject: Bug #78939 [Com]: file_exists produces different results with TS and NTS builds
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224200@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 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: No! I am just reporting, that relative path with drive letter is not resolved correctly. If this path format should be supported, it needs to be resolved like PHP resolve any other relative relative paths. PHP currently ignores this fact completely and resolves relative paths with drive letter like absolute ones. Previous Comments: ------------------------------------------------------------------------ [2019-12-10 14:12:07] requinix@php.net And if your expected behavior on Windows is that "C:/x.txt" and "C:/X.TXT" are two different files, you would be equally wrong. ------------------------------------------------------------------------ [2019-12-10 13:30:36] michael dot vorisek at email dot cz Yes, only contemplation for easier fix and to prevent missuses... The current issue is that PHP does not resolves relative paths the same way. The expected behaviour is, if your current directory is in C: drive, then all usages like: "x.txt", "./x.txt" and "C:x.txt" point to the same file. ------------------------------------------------------------------------ [2019-12-10 13:22:57] requinix@php.net That might have been a bit blunt. My point is, you had some sort of problem that you tracked down (congratulations) to some sort of incorrect file path configuration... code... something. And now you have learned that "C:x.txt" and "C:/x.txt" can potentially mean two different things because the former is a relative path and the latter is absolute. Normally this sort of situation becomes resolved at this point because it's considered an issue of user education, and once the teaching is done and the code is fixed, everything starts working again. But you're apparently looking for something more and I, personally, am not seeing what should happen next. It's not like the behavior is wrong - maybe it's a bit unexpected, but that isn't PHP's fault. The only thing I can think of is documentation, but there are *tons* of little Windows nuances out there and I don't think it's reasonable to expect PHP to try to cover them. Prohibit the unusual behavior? That seems like it would punish more people for using the feature than help people who were accidentally using it (and somehow not noticing a problem?). ------------------------------------------------------------------------ [2019-12-10 13:06:22] requinix@php.net There's no support to remove. It's Windows doing this, not PHP. What you want is to *add a restriction* that PHP on Windows will not allow an uncommon but very much valid pattern for a file path. And what's the rationale for this, again? Because "a lot of people are not aware of it"? Got anything better? ------------------------------------------------------------------------ [2019-12-10 12:58:27] michael dot vorisek at email dot cz 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. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=78939 -- Edit this bug report at https://bugs.php.net/bug.php?id=78939&edit=1

« previous php.bugs (#224200) next »