mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #76943: Inconsistent stream_wrapper_restore() errors
This commit is contained in:
commit
ff0f6c26c2
3 changed files with 36 additions and 6 deletions
1
NEWS
1
NEWS
|
@ -24,6 +24,7 @@ PHP NEWS
|
|||
|
||||
- Standard:
|
||||
. Fixed bug #80114 (parse_url does not accept URLs with port 0). (cmb, twosee)
|
||||
. Fixed bug #76943 (Inconsistent stream_wrapper_restore() errors). (cmb)
|
||||
|
||||
01 Oct 2020, PHP 7.4.11
|
||||
|
||||
|
|
28
ext/standard/tests/streams/bug76943.phpt
Normal file
28
ext/standard/tests/streams/bug76943.phpt
Normal file
|
@ -0,0 +1,28 @@
|
|||
--TEST--
|
||||
Bug #76943 (Inconsistent stream_wrapper_restore() errors)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!in_array('phar', stream_get_wrappers())) die('skip phar wrapper not registered');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(stream_wrapper_restore('foo'));
|
||||
var_dump(stream_wrapper_restore('phar'));
|
||||
|
||||
stream_wrapper_register('bar', 'stdClass');
|
||||
|
||||
var_dump(stream_wrapper_restore('foo'));
|
||||
var_dump(stream_wrapper_restore('phar'));
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: stream_wrapper_restore(): foo:// never existed, nothing to restore in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Notice: stream_wrapper_restore(): phar:// was never changed, nothing to restore in %s on line %d
|
||||
bool(true)
|
||||
|
||||
Warning: stream_wrapper_restore(): foo:// never existed, nothing to restore in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Notice: stream_wrapper_restore(): phar:// was never changed, nothing to restore in %s on line %d
|
||||
bool(true)
|
|
@ -559,23 +559,24 @@ PHP_FUNCTION(stream_wrapper_restore)
|
|||
{
|
||||
zend_string *protocol;
|
||||
php_stream_wrapper *wrapper;
|
||||
HashTable *global_wrapper_hash;
|
||||
HashTable *global_wrapper_hash, *wrapper_hash;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &protocol) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
global_wrapper_hash = php_stream_get_url_stream_wrappers_hash_global();
|
||||
if (php_stream_get_url_stream_wrappers_hash() == global_wrapper_hash) {
|
||||
php_error_docref(NULL, E_NOTICE, "%s:// was never changed, nothing to restore", ZSTR_VAL(protocol));
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
||||
if ((wrapper = zend_hash_find_ptr(global_wrapper_hash, protocol)) == NULL) {
|
||||
php_error_docref(NULL, E_WARNING, "%s:// never existed, nothing to restore", ZSTR_VAL(protocol));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
wrapper_hash = php_stream_get_url_stream_wrappers_hash();
|
||||
if (wrapper_hash == global_wrapper_hash || zend_hash_find_ptr(wrapper_hash, protocol) == wrapper) {
|
||||
php_error_docref(NULL, E_NOTICE, "%s:// was never changed, nothing to restore", ZSTR_VAL(protocol));
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
||||
/* A failure here could be okay given that the protocol might have been merely unregistered */
|
||||
php_unregister_url_stream_wrapper_volatile(protocol);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue