Bug #76943 [Opn->Ver]: stream_wrapper_restore works differently before/after changes to the wrappers

From: Date: Tue, 02 Oct 2018 21:16:24 +0000
Subject: Bug #76943 [Opn->Ver]: stream_wrapper_restore works differently before/after changes to the wrappers
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217380@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76943&edit=1 ID: 76943 Updated by: cmb@php.net Reported by: martin at auswoeger dot com Summary: stream_wrapper_restore works differently before/after changes to the wrappers -Status: Open +Status: Verified Type: Bug Package: Streams related PHP Version: 7.2.10 -Assigned To: +Assigned To: pollita Block user comment: N Private report: N New Comment: I can confirm this behavior. Just swapping the two if statements[1] would yield the “expected” 'foo' related behavior. However, given that the documentation states “Restores a previously unregistered built-in wrapper”, I'm somewhat surprised that the message doesn't say that 'foo' is not a built-in wrapper. Sara, since you've implemented stream_wrapper_restore()[3], what do you think? [1] <https://github.com/php/php-src/blob/php-7.3.0RC2/main/streams/userspace.c#L566-L574> [2] <http://php.net/manual/en/function.stream-wrapper-restore.php> [3] <http://git.php.net/?p=php-src.git;a=commit;h=955b43ba129fabd10b7d7363a2d92d7ce9c4b228> Previous Comments: ------------------------------------------------------------------------ [2018-09-27 21:21:49] martin at auswoeger dot com Description: ------------ The stream_wrapper_restore() function behaves very differently before and after one of the stream_wrapper_(un)register functions was called. It returns different values and triggers different notices. Test script: --------------- <?php echo "\nrestore foo: "; var_dump(stream_wrapper_restore('foo')); echo "\nrestore phar: "; var_dump(stream_wrapper_restore('phar')); stream_wrapper_register('bar', 'stdClass'); echo "\nrestore foo: "; var_dump(stream_wrapper_restore('foo')); echo "\nrestore phar: "; var_dump(stream_wrapper_restore('phar')); Expected result: ---------------- restore foo: Warning: stream_wrapper_restore(): foo:// never existed, nothing to restore in … on line 3 bool(false) restore phar: Notice: stream_wrapper_restore(): phar:// was never changed, nothing to restore in … on line 4 bool(true) restore foo: Warning: stream_wrapper_restore(): foo:// never existed, nothing to restore in … on line 8 bool(false) restore phar: Notice: stream_wrapper_restore(): phar:// was never changed, nothing to restore in … on line 9 bool(true) Actual result: -------------- restore foo: Notice: stream_wrapper_restore(): foo:// was never changed, nothing to restore in … on line 3 bool(true) restore phar: Notice: stream_wrapper_restore(): phar:// was never changed, nothing to restore in … on line 4 bool(true) restore foo: Warning: stream_wrapper_restore(): foo:// never existed, nothing to restore in … on line 8 bool(false) restore phar: bool(true) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76943&edit=1

« previous php.bugs (#217380) next »