-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Improper long path support for relative paths #10992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Are expected and actual result reversed here? |
I corrected it. |
I tried to reproduce this on my Windows VM (Win10 22H2 so same as yours). I cannot reproduce this behaviour (I tried both with LongPathsEnabled 0 and 1). (*) I can't create a file/directory with 256 or more characters. But in that case the behaviour of |
I change test script. Try again. |
New test script.
I can confirm it on another computer.
|
I can reproduce it, and I have found the root cause. What happens is that for long paths we rely on Windows's path canonicalization to prepend But why does it work on ZTS then? Well, on ZTS we do I suspect that most path-related functions suffer from this problem. I guess we should somehow make it absolute on NTS if we do a canonicalization transformation. (Side question: why is VIRTUAL_DIR ZTS-only?) (*) php-src/Zend/zend_virtual_cwd.h Lines 52 to 54 in bf123da
|
Yes, I use NTS. |
Relative paths are passed to the ioutils APIs, these are not properly converted to long paths. If the path length already exceeds a given threshold (usually 259 characters, but only 247 for `mkdir()`), the long path prefix is prepended, resulting in an invalid path, since long paths have to be absolute. If the path length does not exceed that threshold, no conversion to a long path is done, although that may be necessary. Thus we take the path length of the current working directory into account when checking the threshold, and prepend it to the filename if necessary. Since this is only relevant for NTS builds, and using the current working directory of the process would be erroneous for ZTS builds, we skip the new code for ZTS builds.
Description
The following code:
Resulted in this output:
But I expected this output instead:
PHP Version
PHP 8.2.4
Operating System
Windows 10 Pro 22H2 (10.0.19045.2788)
The text was updated successfully, but these errors were encountered: