diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 4edc6361605fb..508fa35430d80 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -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) { RETURN_BOOL(S_ISDIR(Z_LVAL_P(return_value))); } else { if (!allow_links diff --git a/ext/spl/tests/gh9674.phpt b/ext/spl/tests/gh9674.phpt new file mode 100644 index 0000000000000..52f52c072496f --- /dev/null +++ b/ext/spl/tests/gh9674.phpt @@ -0,0 +1,40 @@ +--TEST-- +Bug GH-9674 (RecursiveDirectoryIterator regression wrt. junctions) +--SKIPIF-- + +--FILE-- +getFilename()); +} +?> +--CLEAN-- + +--EXPECT-- +string(1) "." +string(2) ".." +string(5) "a.txt" +string(5) "b.txt" +string(1) "." +string(2) ".." +string(5) "c.txt" diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c index 83fc6837c630c..e3961f8a66bd7 100644 --- a/ext/standard/filestat.c +++ b/ext/standard/filestat.c @@ -844,7 +844,7 @@ PHPAPI void php_stat(zend_string *filename, int type, zval *return_value) memcpy(&BG(lssb), &ssb, sizeof(php_stream_statbuf)); } if (!(flags & PHP_STREAM_URL_STAT_LINK) - || !S_ISLNK(ssb.sb.st_mode)) { + || (!S_ISLNK(ssb.sb.st_mode) && ssb.sb.st_mode != 0)) { if (BG(CurrentStatFile)) { zend_string_release(BG(CurrentStatFile)); }