Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
--TEST--
unserialize_callback_func INI setting set multiple times during runtime
--FILE--
<?php

function unserialize_cb_original($name)
{
ini_set('unserialize_callback_func', 'unserialize_cb_changed');
}

function unserialize_cb_changed($name)
{
}

ini_set('unserialize_callback_func', 'unserialize_cb_original');

unserialize('O:3:"FOO":0:{}');

var_dump(ini_get('unserialize_callback_func'));

ini_restore('unserialize_callback_func');

var_dump(ini_get('unserialize_callback_func'));

?>
--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) ""
30 changes: 17 additions & 13 deletions main/streams/streams.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down