Commit ae59c694674 for php.net

commit ae59c694674aa7e65950d264d2ccaf0d1bedcf5c
Author: David Carlier <devnexen@gmail.com>
Date:   Sun Dec 14 14:44:04 2025 +0000

    ext/spl: DirectoryIterator to support modern filesytems.

    With filesystems with builtin large capacity such as ZFS, Btfrs, NTFS
     or even ext4 with large_dir feature enabled, an int to represent an
    entry index is falling short, thus risking overflows.

    A zend_long however should cover this need without  increasing out
    internal data structure.

    close GH-20705

diff --git a/NEWS b/NEWS
index 671d2b57a67..534daec19b3 100644
--- a/NEWS
+++ b/NEWS
@@ -50,6 +50,10 @@ PHP                                                                        NEWS
   . Soap::__setCookie() when cookie name is a digit is now not stored and represented
     as a string anymore but a int. (David Carlier)

+- SPL:
+  . DirectoryIterator key can now work better with filesystem supporting larger
+    directory indexing. (David Carlier)
+
 - Standard:
   . Fixed bug GH-19926 (reset internal pointer earlier while splicing array
     while COW violation flag is still set). (alexandre-daubois)
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index 6a5fc1757f2..86e4b11334c 100644
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -414,7 +414,7 @@ static zend_object *spl_filesystem_object_clone(zend_object *old_object)
 			spl_filesystem_dir_open(intern, source->path);
 			/* read until we hit the position in which we were before */
 			bool skip_dots = SPL_HAS_FLAG(source->flags, SPL_FILE_DIR_SKIPDOTS);
-			int index;
+			zend_long index;
 			for (index = 0; index < source->u.dir.index; ++index) {
 				do {
 					spl_filesystem_dir_read(intern);
diff --git a/ext/spl/spl_directory.h b/ext/spl/spl_directory.h
index 549dfb1dc4d..a2d1d8d8547 100644
--- a/ext/spl/spl_directory.h
+++ b/ext/spl/spl_directory.h
@@ -62,7 +62,7 @@ struct _spl_filesystem_object {
 		struct {
 			php_stream         *dirp;
 			zend_string        *sub_path;
-			int                index;
+			zend_long          index;
 			zend_function      *func_rewind;
 			zend_function      *func_next;
 			zend_function      *func_valid;