php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76943 stream_wrapper_restore works differently before/after changes to the wrappers
Submitted: 2018-09-27 21:21 UTC Modified: 2018-10-02 21:16 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: martin at auswoeger dot com Assigned: pollita (profile)
Status: Verified Package: Streams related
PHP Version: 7.2.10 OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2018-09-27 21:21 UTC] 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)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-10-02 21:16 UTC] cmb@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: pollita
 [2018-10-02 21:16 UTC] cmb@php.net
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>
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Apr 22 02:01:25 2019 UTC