Req #80919 [Com]: stream wrapper register first params prompt failed If underlined

From: Date: Tue, 30 Mar 2021 15:17:38 +0000
Subject: Req #80919 [Com]: stream wrapper register first params prompt failed If underlined
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233070@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 Comment by: 352386674 at qq dot com Reported by: 352386674 at qq dot com Summary: stream wrapper register first params prompt failed If underlined 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: Sorry for the carelessness! Thank you for your explanation in the document Previous Comments: ------------------------------------------------------------------------ [2021-03-30 15:07:19] pollita@php.net Actually, on a second look, while your repro script is buggy, the real issue is that underscores are not valid scheme names. Scheme names must contain ONLY [a-zA-Z0-9.+-] and no other characters. This doesn't appear to be well documented, so I'll add a section to the manual. ------------------------------------------------------------------------ [2021-03-30 15:04:24] pollita@php.net 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. ------------------------------------------------------------------------ [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

« previous php.bugs (#233070) next »