diff --git a/ext/standard/tests/serialize/unserialize_callback_func_INI_modifications.phpt b/ext/standard/tests/serialize/unserialize_callback_func_INI_modifications.phpt new file mode 100644 index 000000000000..c337903ce293 --- /dev/null +++ b/ext/standard/tests/serialize/unserialize_callback_func_INI_modifications.phpt @@ -0,0 +1,29 @@ +--TEST-- +unserialize_callback_func INI setting set multiple times during runtime +--FILE-- + +--EXPECTF-- +Warning: unserialize(): Function unserialize_cb_original() hasn't defined the class it was called for in %s on line %d +string(22) "unserialize_cb_changed" +string(0) "" diff --git a/main/streams/streams.c b/main/streams/streams.c index d7d3d70782fc..740a1d7a6e06 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -2034,21 +2034,25 @@ PHPAPI php_stream *_php_stream_opendir(const char *path, int options, path_to_open = path; wrapper = php_stream_locate_url_wrapper(path, &path_to_open, options); + if (UNEXPECTED(wrapper == NULL)) { + php_stream_wrapper_warn_name(PHP_STREAM_ERROR_WRAPPER_DEFAULT_NAME, context, options, OpenFailed, + "Failed to open directory"); + return NULL; + } - if (wrapper && wrapper->wops->dir_opener) { - stream = wrapper->wops->dir_opener(wrapper, - path_to_open, "r", options & ~REPORT_ERRORS, NULL, - context STREAMS_REL_CC); - - if (stream) { - stream->wrapper = wrapper; - stream->flags |= PHP_STREAM_FLAG_NO_BUFFER | PHP_STREAM_FLAG_IS_DIR; - } - } else if (wrapper) { - php_stream_wrapper_log_warn(wrapper, context, options & ~REPORT_ERRORS, - NoOpener, "not implemented"); + if (UNEXPECTED(!wrapper->wops->dir_opener)) { + php_stream_wrapper_warn(wrapper, context, options, NoOpener, "Failed to open directory: not implemented"); + return NULL; } - if (stream == NULL && (options & REPORT_ERRORS)) { + + stream = wrapper->wops->dir_opener(wrapper, + path_to_open, "r", options & ~REPORT_ERRORS, NULL, + context STREAMS_REL_CC); + + if (stream) { + stream->wrapper = wrapper; + stream->flags |= PHP_STREAM_FLAG_NO_BUFFER | PHP_STREAM_FLAG_IS_DIR; + } else if (options & REPORT_ERRORS) { php_stream_display_wrapper_errors(wrapper, context, PHP_STREAM_EC(OpenFailed), "Failed to open directory"); }