Use better way to determine stream type in encryption stream wrapper

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2018-04-24 11:34:08 +02:00 committed by Roeland Jago Douma
parent c27016b1d1
commit 57ba18f47f
No known key found for this signature in database
GPG key ID: F941078878347C0C

View file

@ -195,10 +195,10 @@ class Encryption extends Wrapper {
protected static function wrapSource($source, $context, $protocol, $class, $mode = 'r+') {
try {
stream_wrapper_register($protocol, $class);
if (@rewinddir($source) === false) {
$wrapped = fopen($protocol . '://', $mode, false, $context);
} else {
if (self::isDirectoryHandle($source)) {
$wrapped = opendir($protocol . '://', $context);
} else {
$wrapped = fopen($protocol . '://', $mode, false, $context);
}
} catch (\BadMethodCallException $e) {
stream_wrapper_unregister($protocol);