php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76943 Inconsistent stream_wrapper_restore() errors
Submitted: 2018-09-27 21:21 UTC Modified: 2020-09-22 11:29 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: cmb (profile)
Status: Closed Package: Streams related
PHP Version: 7.2.10 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: martin at auswoeger dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

Pull requests:

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>
 [2020-09-22 11:29 UTC] cmb@php.net
-Summary: stream_wrapper_restore works differently before/after changes to the wrappers +Summary: Inconsistent stream_wrapper_restore() errors -Assigned To: pollita +Assigned To: cmb
 [2020-09-22 11:55 UTC] cmb@php.net
The following pull request has been associated:

Patch Name: Fix #76943: Inconsistent stream_wrapper_restore() errors
On GitHub:  https://github.com/php/php-src/pull/6183
Patch:      https://github.com/php/php-src/pull/6183.patch
 [2020-09-22 14:15 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=5ed0602ec622274bf5672304ae414e5ecb2e5167
Log: Fix #76943: Inconsistent stream_wrapper_restore() errors
 [2020-09-22 14:15 UTC] cmb@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC