merge in default context / Vfs::$user, otherwise we have to fix all code already using context

This commit is contained in:
Ralf Becker 2020-09-23 11:52:02 +02:00
parent 7cc46f04e1
commit 73e2e71e9a
2 changed files with 9 additions and 4 deletions

View File

@ -393,11 +393,11 @@ class Vfs extends Vfs\Base
}
// make all find options available as stream context option "find", to allow plugins to use them
$context = stream_context_create(array_merge_recursive(stream_context_get_options(stream_context_get_default()), [
$context = stream_context_create([
self::SCHEME => [
'find' => $options,
],
]));
]);
$url = $options['url'];

View File

@ -48,8 +48,13 @@ trait UserContextTrait
{
$this->context = stream_context_get_default();
}
// if context set by PHP contains no user, set user from our default context (Vfs::$user)
elseif (empty(stream_context_get_options($this->context)[Vfs::SCHEME]['user']))
{
stream_context_set_option($this->context, stream_context_get_options(stream_context_get_default()));
}
if(is_string($url_or_context))
if (is_string($url_or_context))
{
$this->check_set_context($url_or_context, true);
}
@ -167,7 +172,7 @@ trait UserContextTrait
switch($name)
{
case 'user':
return $this->context ? stream_context_get_options($this->context)[Vfs::SCHEME]['user'] : null;
return $this->context ? stream_context_get_options($this->context)[Vfs::SCHEME]['user'] : Vfs::$user;
}
return null;
}