Skip to content

Fix GH-17067: glob:// wrapper doesn't cater to CWD for ZTS builds #17074

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

Closed
wants to merge 4 commits into from

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Dec 6, 2024

glob(3) doesn't know the virtual CWD of PHP, so we need to pass an absolute path for ZTS builds. In lack of a reusable routine, we copy the code from glob() and adapt as needed.


In my opinion, there should be some routine (likely in zend_virtual_cwd) which makes a path absolute, but without normalization or even getting the real path (just quickly prepending the VCWD if necessary). I'm not quite convinced that we should introduce that routine for stable branches, though.

`glob(3)` doesn't know the virtual CWD of PHP, so we need to pass an
absolute path for ZTS builds.  In lack of a reusable routine, we copy
the code from `glob()` and adapt as needed.
@cmb69 cmb69 linked an issue Dec 6, 2024 that may be closed by this pull request
cmb69 added 2 commits December 7, 2024 20:36
We should strip the CWD whenever we call `php_glob_stream_path_split()`,
but that would require to store the value in `glob_s_t` what we cannot
do for stable PHP versions since it would be an ABI break.  Thus we
traverse `gl_pathv`, and strip the prepended CWD there.
Copy link
Member

@bukka bukka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should work. It wouldn't work for glob with braces (I actually started testing it with it to check if this still works) but glob wrapper does not pass that flag so braces cannot be used so using IS_ABSOLUTE_PATH should be reliable for identifying absolute path here.

@cmb69 cmb69 marked this pull request as ready for review December 8, 2024 17:59
@cmb69 cmb69 closed this in 53b69ba Dec 18, 2024
charmitro pushed a commit to wasix-org/php that referenced this pull request Mar 13, 2025
`glob(3)` doesn't know the virtual CWD of PHP, so we need to pass an
absolute path for ZTS builds.  In lack of a reusable routine, we copy
the code from `glob()` and adapt as needed.

Closes phpGH-17074.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

glob:// wrapper doesn't cater to CWD for ZTS builds
2 participants