From 1d6175d5cdf838a3d4da7c4d16238f4c292f270d Mon Sep 17 00:00:00 2001 From: CHU Zhaowei Date: Sun, 8 Sep 2019 09:29:32 +0000 Subject: [PATCH 1/3] fix bug #72884 isCloneable() on SplFileObject should return false --- ext/spl/spl_directory.c | 1 + ext/spl/tests/bug72884.phpt | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 ext/spl/tests/bug72884.phpt diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 049b517c46def..ad7fad4f0d087 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -3157,6 +3157,7 @@ PHP_MINIT_FUNCTION(spl_directory) REGISTER_SPL_IMPLEMENTS(RecursiveDirectoryIterator, RecursiveIterator); memcpy(&spl_filesystem_object_check_handlers, &spl_filesystem_object_handlers, sizeof(zend_object_handlers)); + spl_filesystem_object_check_handlers.clone_obj = 0; spl_filesystem_object_check_handlers.get_method = spl_filesystem_object_get_method_check; #ifdef HAVE_GLOB diff --git a/ext/spl/tests/bug72884.phpt b/ext/spl/tests/bug72884.phpt new file mode 100644 index 0000000000000..178e0e1d70627 --- /dev/null +++ b/ext/spl/tests/bug72884.phpt @@ -0,0 +1,10 @@ +--TEST-- +Bug #72884: isCloneable() on SplFileObject should return false +--FILE-- +isCloneable()); + +--EXPECT-- +bool(false) From 65d2a47780160a23e062a7d2fa105247deb38fe7 Mon Sep 17 00:00:00 2001 From: CHU Zhaowei Date: Sun, 8 Sep 2019 10:38:41 +0000 Subject: [PATCH 2/3] clean up --- ext/spl/spl_directory.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index ad7fad4f0d087..a1f616934066e 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -371,8 +371,7 @@ static zend_object *spl_filesystem_object_clone(zval *zobject) intern->u.dir.index = index; break; case SPL_FS_FILE: - zend_throw_error(NULL, "An object of class %s cannot be cloned", ZSTR_VAL(old_object->ce->name)); - return new_object; + ZEND_ASSERT(0); } intern->file_class = source->file_class; @@ -3157,7 +3156,7 @@ PHP_MINIT_FUNCTION(spl_directory) REGISTER_SPL_IMPLEMENTS(RecursiveDirectoryIterator, RecursiveIterator); memcpy(&spl_filesystem_object_check_handlers, &spl_filesystem_object_handlers, sizeof(zend_object_handlers)); - spl_filesystem_object_check_handlers.clone_obj = 0; + spl_filesystem_object_check_handlers.clone_obj = NULL; spl_filesystem_object_check_handlers.get_method = spl_filesystem_object_get_method_check; #ifdef HAVE_GLOB From f79b3e5c636a0f3711ccec3c29912e961fb95baa Mon Sep 17 00:00:00 2001 From: CHU Zhaowei Date: Sun, 8 Sep 2019 10:38:54 +0000 Subject: [PATCH 3/3] fix test --- ext/spl/tests/bug72888.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/spl/tests/bug72888.phpt b/ext/spl/tests/bug72888.phpt index 7d2fc6db08a03..d354490f88255 100644 --- a/ext/spl/tests/bug72888.phpt +++ b/ext/spl/tests/bug72888.phpt @@ -12,7 +12,7 @@ try { var_dump($y); ?> --EXPECTF-- -string(49) "An object of class SplFileObject cannot be cloned" +string(60) "Trying to clone an uncloneable object of class SplFileObject" Notice: Undefined variable: y in %sbug72888.php on line %d NULL