diff --git a/api/src/Vfs.php b/api/src/Vfs.php index 2004bcbbac..4397ca03e7 100644 --- a/api/src/Vfs.php +++ b/api/src/Vfs.php @@ -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']; diff --git a/api/src/Vfs/UserContextTrait.php b/api/src/Vfs/UserContextTrait.php index fb9c001320..3a44c94ef6 100644 --- a/api/src/Vfs/UserContextTrait.php +++ b/api/src/Vfs/UserContextTrait.php @@ -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; }