Req #80919 [Opn->Nab]: stream wrapper register first params prompt failed If underlined
| From: | pollita@php.net | Date: | Tue, 30 Mar 2021 15:04:24 +0000 |
| Subject: | Req #80919 [Opn->Nab]: stream wrapper register first params prompt failed If underlined | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-233068@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80919&edit=1
ID: 80919
Updated by: pollita@php.net
Reported by: 352386674 at qq dot com
Summary: stream wrapper register first params prompt failed
If underlined
-Status: Open
+Status: Not a bug
Type: Feature/Change Request
Package: *Directory/Filesystem functions
Operating System: Ubuntu PHP version 7.4.8(cli)
PHP Version: 7.4.16
Block user comment: N
Private report: N
New Comment:
There is a bug in your repro script:
if(in_array('diy_wrapper', $wrapper_list))
"diy" != "dir"
If you had the correct test there, you would see that your wrapper is already defined.
Previous Comments:
------------------------------------------------------------------------
[2021-03-30 14:59:21] 352386674 at qq dot com
Description:
------------
<?php
class StreamDir
{
public $context = NULL;
public function dir_opendir(string $path, int $options)
{
return false;
}
}
$wrapper_list = stream_get_wrappers();
if(in_array('diy', $wrapper_list))
{
echo "stream wrapper already\n";
exit(0);
}
stream_wrapper_register("dir", "StreamDir");
$context = stream_context_create(['dir' => []]);
$dir = opendir('dir://Directory path', $context);
var_dump($dir);
Test script:
---------------
<?php
class StreamDir
{
public $context = NULL;
public function dir_opendir(string $path, int $options)
{
return false;
}
}
$wrapper_list = stream_get_wrappers();
if(in_array('diy_wrapper', $wrapper_list))
{
echo "stream wrapper already\n";
exit(0);
}
stream_wrapper_register("dir_wrapper", "StreamDir");
$context = stream_context_create(['dir_wrapper' => []]);
$dir = opendir('dir_wrapper://Directory path', $context);
var_dump($dir);
Expected result:
----------------
tips open directory failed
Actual result:
--------------
Warning: stream_wrapper_register(): Invalid protocol scheme specified. Unable to register wrapper
class StreamDir to dir_wrapper:// in PHP run script path
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80919&edit=1