Skip to content
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

Fix GH-9674: RecursiveDirectoryIterator regression wrt. junctions #9774

Open
wants to merge 2 commits into
base: PHP-8.1
Choose a base branch
from

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Oct 18, 2022

If we lstat() a junction on Windows, it is not S_ISLNK(), but we still must not assume that it is not a link (in the broadest sense). In lack of a proper way to detect that, we use the fact that .st_mode is zero in this case.

If we `lstat()` a junction on Windows, it is not `S_ISLNK()`, but we
still must not assume that it is not a link (in the broadest sense).
In lack of a proper way to detect that, we use the fact that `.st_mode`
is zero in this case.
@cmb69 cmb69 linked an issue Oct 18, 2022 that may be closed by this pull request
@@ -1480,7 +1480,7 @@ PHP_METHOD(RecursiveDirectoryIterator, hasChildren)
php_stat(intern->file_name, FS_LPERMS, return_value);
if (Z_TYPE_P(return_value) == IS_FALSE) {
return;
} else if (!S_ISLNK(Z_LVAL_P(return_value))) {
} else if (!S_ISLNK(Z_LVAL_P(return_value)) && Z_LVAL_P(return_value) != 0) {
Copy link
Member Author

Choose a reason for hiding this comment

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

We should at least add a comment, or better encapsulate the additional check in a macro/function (naming suggestions welcome!) However, I have doubts that it is even correct that lstat("junction")["mode"] == 0.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ping! I'd be really happy to get some input about naming the macro.

@cmb69 cmb69 marked this pull request as ready for review October 25, 2022 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RecursiveDirectoryIterator regression wrt. junctions
1 participant