diff --git a/3rdparty b/3rdparty
index aea1df9dcc0ae..8a030d70b84a7 160000
--- a/3rdparty
+++ b/3rdparty
@@ -1 +1 @@
-Subproject commit aea1df9dcc0ae1b774e15edf07a470198b952e45
+Subproject commit 8a030d70b84a7367c101bce29b1be044322c0a8f
diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php
index 3087b752f0169..a4948a795a149 100644
--- a/apps/dav/lib/Connector/Sabre/File.php
+++ b/apps/dav/lib/Connector/Sabre/File.php
@@ -494,7 +494,7 @@ public function getContentType() {
}
/**
- * @return array|false
+ * @return array|bool
*/
public function getDirectDownload() {
if (\OCP\App::isEnabled('encryption')) {
diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php
index d995a016db11f..0f67877d1480a 100644
--- a/apps/files_external/lib/Lib/Storage/SMB.php
+++ b/apps/files_external/lib/Lib/Storage/SMB.php
@@ -441,7 +441,7 @@ public function hasUpdated($path, $time) {
/**
* @param string $path
* @param string $mode
- * @return resource|false
+ * @return resource|bool
*/
public function fopen($path, $mode) {
$fullPath = $this->buildPath($path);
diff --git a/apps/workflowengine/lib/Check/FileMimeType.php b/apps/workflowengine/lib/Check/FileMimeType.php
index 8d9e2468ebd84..dfeb56a665b47 100644
--- a/apps/workflowengine/lib/Check/FileMimeType.php
+++ b/apps/workflowengine/lib/Check/FileMimeType.php
@@ -122,8 +122,7 @@ protected function getActualValue() {
return $this->cacheAndReturnMimeType($this->storage->getId(), $this->path, 'httpd/unix-directory');
}
- if ($this->storage->file_exists($this->path)) {
- $path = $this->storage->getLocalFile($this->path);
+ if ($this->storage->file_exists($this->path) && is_string($path = $this->storage->getLocalFile($this->path))) {
$mimeType = $this->mimeTypeDetector->detectContent($path);
return $this->cacheAndReturnMimeType($this->storage->getId(), $this->path, $mimeType);
}
diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml
index 32b9c8d8e06ab..4c35127186368 100644
--- a/build/psalm-baseline.xml
+++ b/build/psalm-baseline.xml
@@ -1724,12 +1724,8 @@
-
- $this->nonMaskedStorage->fopen($this->getUnjailedPath($path), $mode)
+
$this->sourceRootInfo
- false
- false
- false
ICacheEntry
@@ -2792,7 +2788,7 @@
$this
- $this
+ $this->create('core_ajax_update', '/core/ajax/update.php')
@@ -3068,10 +3064,11 @@
false
-
+
$this->tar->extractInString($path)
-
+
+ resource
string
@@ -3083,6 +3080,10 @@
boolean|null
boolean|null
+
+
+ resource
+
@@ -4213,29 +4214,6 @@
-
- $result
- $this->storage->file_get_contents($this->findPathToUse($path))
- $this->storage->filemtime($this->findPathToUse($path))
- $this->storage->filesize($this->findPathToUse($path))
- $this->storage->free_space($this->findPathToUse($path))
- $this->storage->getETag($this->findPathToUse($path))
- $this->storage->getLocalFile($this->findPathToUse($path))
- $this->storage->getMimeType($this->findPathToUse($path))
- $this->storage->hash($type, $this->findPathToUse($path), $raw)
- $this->storage->opendir($this->findPathToUse($path))
- $this->storage->search($query)
- $this->storage->stat($this->findPathToUse($path))
-
-
- bool
-
-
- $this->storage->filetype($this->findPathToUse($path))
-
-
- bool
-
$this->namesCache
$this->namesCache
@@ -4253,16 +4231,6 @@
-
- $stat
- $this->storage->file_get_contents($path)
- $this->storage->filesize($path)
- $this->storage->getLocalFile($path)
- false
-
-
- resource|bool
-
$source
$target
@@ -4290,23 +4258,6 @@
-
- $this->getWrapperStorage()->file_get_contents($this->getUnjailedPath($path))
- $this->getWrapperStorage()->filemtime($this->getUnjailedPath($path))
- $this->getWrapperStorage()->filesize($this->getUnjailedPath($path))
- $this->getWrapperStorage()->fopen($this->getUnjailedPath($path), $mode)
- $this->getWrapperStorage()->free_space($this->getUnjailedPath($path))
- $this->getWrapperStorage()->getETag($this->getUnjailedPath($path))
- $this->getWrapperStorage()->getLocalFile($this->getUnjailedPath($path))
- $this->getWrapperStorage()->getMimeType($this->getUnjailedPath($path))
- $this->getWrapperStorage()->hash($type, $this->getUnjailedPath($path), $raw)
- $this->getWrapperStorage()->opendir($this->getUnjailedPath($path))
- $this->getWrapperStorage()->search($query)
- $this->getWrapperStorage()->stat($this->getUnjailedPath($path))
-
-
- bool
-
$this->getWrapperStorage()->filetype($this->getUnjailedPath($path))
@@ -4314,16 +4265,7 @@
bool
-
-
- $this->checkMask($permissions) ? parent::fopen($path, $mode) : false
-
-
-
- $source
- $this->storage->free_space($path)
-
$extension === 'part'
@@ -4339,30 +4281,10 @@
-
- $this->getWrapperStorage()->file_get_contents($path)
- $this->getWrapperStorage()->filemtime($path)
- $this->getWrapperStorage()->filesize($path)
- $this->getWrapperStorage()->fopen($path, $mode)
- $this->getWrapperStorage()->free_space($path)
- $this->getWrapperStorage()->getDirectDownload($path)
- $this->getWrapperStorage()->getETag($path)
- $this->getWrapperStorage()->getLocalFile($path)
- $this->getWrapperStorage()->getMimeType($path)
- $this->getWrapperStorage()->hash($type, $path, $raw)
- $this->getWrapperStorage()->opendir($path)
- $this->getWrapperStorage()->search($query)
- $this->getWrapperStorage()->stat($path)
-
-
- bool
-
-
- $this->getWrapperStorage()->filetype($path)
+
$this->getWrapperStorage()->test()
-
- bool
+
true
@@ -4774,9 +4696,12 @@
-
+
$file->getStorage()->getLocalFile($file->getInternalPath())
-
+
+
+ string
+
diff --git a/lib/composer/composer/installed.json b/lib/composer/composer/installed.json
index fe51488c7066f..f20a6c47c6d4f 100644
--- a/lib/composer/composer/installed.json
+++ b/lib/composer/composer/installed.json
@@ -1 +1,5 @@
-[]
+{
+ "packages": [],
+ "dev": false,
+ "dev-package-names": []
+}
diff --git a/lib/private/Files/ObjectStore/StorageObjectStore.php b/lib/private/Files/ObjectStore/StorageObjectStore.php
index acf46758956b8..2076bb3f88b1f 100644
--- a/lib/private/Files/ObjectStore/StorageObjectStore.php
+++ b/lib/private/Files/ObjectStore/StorageObjectStore.php
@@ -26,6 +26,7 @@
use OCP\Files\ObjectStore\IObjectStore;
use OCP\Files\Storage\IStorage;
+use function is_resource;
/**
* Object store that wraps a storage backend, mostly for testing purposes
@@ -57,11 +58,11 @@ public function getStorageId() {
*/
public function readObject($urn) {
$handle = $this->storage->fopen($urn, 'r');
- if ($handle) {
+ if (is_resource($handle)) {
return $handle;
- } else {
- throw new \Exception();
}
+
+ throw new \Exception();
}
/**
diff --git a/lib/private/Files/SimpleFS/NewSimpleFile.php b/lib/private/Files/SimpleFS/NewSimpleFile.php
index b8e50941e5f6c..fb4346aae0fcb 100644
--- a/lib/private/Files/SimpleFS/NewSimpleFile.php
+++ b/lib/private/Files/SimpleFS/NewSimpleFile.php
@@ -208,7 +208,7 @@ public function read() {
/**
* Open the file as stream for writing, resulting resource can be operated as stream like the result from php's own fopen
*
- * @return resource
+ * @return resource|bool
* @throws \OCP\Files\NotPermittedException
* @since 14.0.0
*/
diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php
index 6a530877f43fe..bddb1f4a29422 100644
--- a/lib/private/Files/Storage/Common.php
+++ b/lib/private/Files/Storage/Common.php
@@ -630,8 +630,9 @@ public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $t
}
}
- if ($result and $preserveMtime) {
- $this->touch($targetInternalPath, $sourceStorage->filemtime($sourceInternalPath));
+ if ($result && $preserveMtime) {
+ $mtime = $sourceStorage->filemtime($sourceInternalPath);
+ $this->touch($targetInternalPath, is_int($mtime) ? $mtime : null);
}
if (!$result) {
diff --git a/lib/private/Files/Storage/Wrapper/Encoding.php b/lib/private/Files/Storage/Wrapper/Encoding.php
index 02e82211dab4b..33a599ee46965 100644
--- a/lib/private/Files/Storage/Wrapper/Encoding.php
+++ b/lib/private/Files/Storage/Wrapper/Encoding.php
@@ -156,7 +156,7 @@ public function rmdir($path) {
* see https://www.php.net/manual/en/function.opendir.php
*
* @param string $path
- * @return resource
+ * @return resource|bool
*/
public function opendir($path) {
return $this->storage->opendir($this->findPathToUse($path));
@@ -187,7 +187,7 @@ public function is_file($path) {
* only the following keys are required in the result: size and mtime
*
* @param string $path
- * @return array
+ * @return array|bool
*/
public function stat($path) {
return $this->storage->stat($this->findPathToUse($path));
@@ -197,7 +197,7 @@ public function stat($path) {
* see https://www.php.net/manual/en/function.filetype.php
*
* @param string $path
- * @return bool
+ * @return string|bool
*/
public function filetype($path) {
return $this->storage->filetype($this->findPathToUse($path));
@@ -208,7 +208,7 @@ public function filetype($path) {
* The result for filesize when called on a folder is required to be 0
*
* @param string $path
- * @return int
+ * @return int|bool
*/
public function filesize($path) {
return $this->storage->filesize($this->findPathToUse($path));
@@ -289,7 +289,7 @@ public function file_exists($path) {
* see https://www.php.net/manual/en/function.filemtime.php
*
* @param string $path
- * @return int
+ * @return int|bool
*/
public function filemtime($path) {
return $this->storage->filemtime($this->findPathToUse($path));
@@ -299,7 +299,7 @@ public function filemtime($path) {
* see https://www.php.net/manual/en/function.file_get_contents.php
*
* @param string $path
- * @return string
+ * @return string|bool
*/
public function file_get_contents($path) {
return $this->storage->file_get_contents($this->findPathToUse($path));
@@ -358,7 +358,7 @@ public function copy($path1, $path2) {
*
* @param string $path
* @param string $mode
- * @return resource
+ * @return resource|bool
*/
public function fopen($path, $mode) {
$result = $this->storage->fopen($this->findPathToUse($path), $mode);
@@ -373,7 +373,7 @@ public function fopen($path, $mode) {
* The mimetype for a folder is required to be "httpd/unix-directory"
*
* @param string $path
- * @return string
+ * @return string|bool
*/
public function getMimeType($path) {
return $this->storage->getMimeType($this->findPathToUse($path));
@@ -385,7 +385,7 @@ public function getMimeType($path) {
* @param string $type
* @param string $path
* @param bool $raw
- * @return string
+ * @return string|bool
*/
public function hash($type, $path, $raw = false) {
return $this->storage->hash($type, $this->findPathToUse($path), $raw);
@@ -395,7 +395,7 @@ public function hash($type, $path, $raw = false) {
* see https://www.php.net/manual/en/function.free_space.php
*
* @param string $path
- * @return int
+ * @return int|bool
*/
public function free_space($path) {
return $this->storage->free_space($this->findPathToUse($path));
@@ -405,7 +405,7 @@ public function free_space($path) {
* search for occurrences of $query in file names
*
* @param string $query
- * @return array
+ * @return array|bool
*/
public function search($query) {
return $this->storage->search($query);
@@ -428,7 +428,7 @@ public function touch($path, $mtime = null) {
* The local version of the file can be temporary and doesn't have to be persistent across requests
*
* @param string $path
- * @return string
+ * @return string|bool
*/
public function getLocalFile($path) {
return $this->storage->getLocalFile($this->findPathToUse($path));
@@ -480,7 +480,7 @@ public function getScanner($path = '', $storage = null) {
* get the ETag for a file or folder
*
* @param string $path
- * @return string
+ * @return string|bool
*/
public function getETag($path) {
return $this->storage->getETag($this->findPathToUse($path));
diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php
index 1a41fcbb89bac..f53db2883466e 100644
--- a/lib/private/Files/Storage/Wrapper/Encryption.php
+++ b/lib/private/Files/Storage/Wrapper/Encryption.php
@@ -49,6 +49,7 @@
use OCP\Files\Mount\IMountPoint;
use OCP\Files\Storage;
use OCP\ILogger;
+use function is_array;
class Encryption extends Wrapper {
use LocalTempFileTrait;
@@ -136,7 +137,7 @@ public function __construct(
* The result for filesize when called on a folder is required to be 0
*
* @param string $path
- * @return int
+ * @return int|bool
*/
public function filesize($path) {
$fullPath = $this->getFullPath($path);
@@ -213,7 +214,7 @@ public function getDirectoryContent($directory): \Traversable {
* see https://www.php.net/manual/en/function.file_get_contents.php
*
* @param string $path
- * @return string
+ * @return string|bool
*/
public function file_get_contents($path) {
$encryptionModule = $this->getEncryptionModule($path);
@@ -491,6 +492,7 @@ public function fopen($path, $mode) {
* @return int unencrypted size
*/
protected function verifyUnencryptedSize($path, $unencryptedSize) {
+ /** @var int $size */
$size = $this->storage->filesize($path);
$result = $unencryptedSize;
@@ -763,8 +765,8 @@ private function copyBetweenStorage(Storage\IStorage $sourceStorage, $sourceInte
throw $e;
}
if ($result) {
- if ($preserveMtime) {
- $this->touch($targetInternalPath, $sourceStorage->filemtime($sourceInternalPath));
+ if ($preserveMtime && is_int($mtime = $sourceStorage->filemtime($sourceInternalPath))) {
+ $this->touch($targetInternalPath, $mtime);
}
$this->updateEncryptedVersion($sourceStorage, $sourceInternalPath, $targetInternalPath, $isRename, false);
} else {
@@ -782,7 +784,7 @@ private function copyBetweenStorage(Storage\IStorage $sourceStorage, $sourceInte
* The local version of the file can be temporary and doesn't have to be persistent across requests
*
* @param string $path
- * @return string
+ * @return string|bool
*/
public function getLocalFile($path) {
if ($this->encryptionManager->isEnabled()) {
@@ -811,10 +813,13 @@ public function isLocal() {
* only the following keys are required in the result: size and mtime
*
* @param string $path
- * @return array
+ * @return array|bool
*/
public function stat($path) {
$stat = $this->storage->stat($path);
+ if (!is_array($stat)) {
+ return $stat;
+ }
$fileSize = $this->filesize($path);
$stat['size'] = $fileSize;
$stat[7] = $fileSize;
diff --git a/lib/private/Files/Storage/Wrapper/Jail.php b/lib/private/Files/Storage/Wrapper/Jail.php
index 26ad82816c58d..a534ec8a492f0 100644
--- a/lib/private/Files/Storage/Wrapper/Jail.php
+++ b/lib/private/Files/Storage/Wrapper/Jail.php
@@ -106,7 +106,7 @@ public function rmdir($path) {
* see https://www.php.net/manual/en/function.opendir.php
*
* @param string $path
- * @return resource
+ * @return resource|bool
*/
public function opendir($path) {
return $this->getWrapperStorage()->opendir($this->getUnjailedPath($path));
@@ -137,7 +137,7 @@ public function is_file($path) {
* only the following keys are required in the result: size and mtime
*
* @param string $path
- * @return array
+ * @return array|bool
*/
public function stat($path) {
return $this->getWrapperStorage()->stat($this->getUnjailedPath($path));
@@ -158,7 +158,7 @@ public function filetype($path) {
* The result for filesize when called on a folder is required to be 0
*
* @param string $path
- * @return int
+ * @return int|bool
*/
public function filesize($path) {
return $this->getWrapperStorage()->filesize($this->getUnjailedPath($path));
@@ -239,7 +239,7 @@ public function file_exists($path) {
* see https://www.php.net/manual/en/function.filemtime.php
*
* @param string $path
- * @return int
+ * @return int|bool
*/
public function filemtime($path) {
return $this->getWrapperStorage()->filemtime($this->getUnjailedPath($path));
@@ -249,7 +249,7 @@ public function filemtime($path) {
* see https://www.php.net/manual/en/function.file_get_contents.php
*
* @param string $path
- * @return string
+ * @return string|bool
*/
public function file_get_contents($path) {
return $this->getWrapperStorage()->file_get_contents($this->getUnjailedPath($path));
@@ -303,7 +303,7 @@ public function copy($path1, $path2) {
*
* @param string $path
* @param string $mode
- * @return resource
+ * @return resource|bool
*/
public function fopen($path, $mode) {
return $this->getWrapperStorage()->fopen($this->getUnjailedPath($path), $mode);
@@ -314,7 +314,7 @@ public function fopen($path, $mode) {
* The mimetype for a folder is required to be "httpd/unix-directory"
*
* @param string $path
- * @return string
+ * @return string|bool
*/
public function getMimeType($path) {
return $this->getWrapperStorage()->getMimeType($this->getUnjailedPath($path));
@@ -326,7 +326,7 @@ public function getMimeType($path) {
* @param string $type
* @param string $path
* @param bool $raw
- * @return string
+ * @return string|bool
*/
public function hash($type, $path, $raw = false) {
return $this->getWrapperStorage()->hash($type, $this->getUnjailedPath($path), $raw);
@@ -336,7 +336,7 @@ public function hash($type, $path, $raw = false) {
* see https://www.php.net/manual/en/function.free_space.php
*
* @param string $path
- * @return int
+ * @return int|bool
*/
public function free_space($path) {
return $this->getWrapperStorage()->free_space($this->getUnjailedPath($path));
@@ -346,7 +346,7 @@ public function free_space($path) {
* search for occurrences of $query in file names
*
* @param string $query
- * @return array
+ * @return array|bool
*/
public function search($query) {
return $this->getWrapperStorage()->search($query);
@@ -369,7 +369,7 @@ public function touch($path, $mtime = null) {
* The local version of the file can be temporary and doesn't have to be persistent across requests
*
* @param string $path
- * @return string
+ * @return string|bool
*/
public function getLocalFile($path) {
return $this->getWrapperStorage()->getLocalFile($this->getUnjailedPath($path));
@@ -432,7 +432,7 @@ public function getWatcher($path = '', $storage = null) {
* get the ETag for a file or folder
*
* @param string $path
- * @return string
+ * @return string|bool
*/
public function getETag($path) {
return $this->getWrapperStorage()->getETag($this->getUnjailedPath($path));
diff --git a/lib/private/Files/Storage/Wrapper/Quota.php b/lib/private/Files/Storage/Wrapper/Quota.php
index 55fbbb0a60b4a..e9a6847e5813f 100644
--- a/lib/private/Files/Storage/Wrapper/Quota.php
+++ b/lib/private/Files/Storage/Wrapper/Quota.php
@@ -95,7 +95,7 @@ protected function getSize($path, $storage = null) {
* Get free space as limited by the quota
*
* @param string $path
- * @return int
+ * @return int|bool
*/
public function free_space($path) {
if ($this->quota < 0 || strpos($path, 'cache') === 0 || strpos($path, 'uploads') === 0) {
@@ -155,7 +155,7 @@ public function copy($source, $target) {
*
* @param string $path
* @param string $mode
- * @return resource
+ * @return resource|bool
*/
public function fopen($path, $mode) {
$source = $this->storage->fopen($path, $mode);
@@ -163,7 +163,7 @@ public function fopen($path, $mode) {
// don't apply quota for part files
if (!$this->isPartFile($path)) {
$free = $this->free_space($path);
- if ($source && $free >= 0 && $mode !== 'r' && $mode !== 'rb') {
+ if ($source && is_int($free) && $free >= 0 && $mode !== 'r' && $mode !== 'rb') {
// only apply quota for files, not metadata, trash or others
if ($this->shouldApplyQuota($path)) {
return \OC\Files\Stream\Quota::wrap($source, $free);
diff --git a/lib/private/Files/Storage/Wrapper/Wrapper.php b/lib/private/Files/Storage/Wrapper/Wrapper.php
index 43e57c688d173..3754956034348 100644
--- a/lib/private/Files/Storage/Wrapper/Wrapper.php
+++ b/lib/private/Files/Storage/Wrapper/Wrapper.php
@@ -97,7 +97,7 @@ public function rmdir($path) {
* see https://www.php.net/manual/en/function.opendir.php
*
* @param string $path
- * @return resource
+ * @return resource|bool
*/
public function opendir($path) {
return $this->getWrapperStorage()->opendir($path);
@@ -128,7 +128,7 @@ public function is_file($path) {
* only the following keys are required in the result: size and mtime
*
* @param string $path
- * @return array
+ * @return array|bool
*/
public function stat($path) {
return $this->getWrapperStorage()->stat($path);
@@ -138,7 +138,7 @@ public function stat($path) {
* see https://www.php.net/manual/en/function.filetype.php
*
* @param string $path
- * @return bool
+ * @return string|bool
*/
public function filetype($path) {
return $this->getWrapperStorage()->filetype($path);
@@ -149,7 +149,7 @@ public function filetype($path) {
* The result for filesize when called on a folder is required to be 0
*
* @param string $path
- * @return int
+ * @return int|bool
*/
public function filesize($path) {
return $this->getWrapperStorage()->filesize($path);
@@ -230,7 +230,7 @@ public function file_exists($path) {
* see https://www.php.net/manual/en/function.filemtime.php
*
* @param string $path
- * @return int
+ * @return int|bool
*/
public function filemtime($path) {
return $this->getWrapperStorage()->filemtime($path);
@@ -240,7 +240,7 @@ public function filemtime($path) {
* see https://www.php.net/manual/en/function.file_get_contents.php
*
* @param string $path
- * @return string
+ * @return string|bool
*/
public function file_get_contents($path) {
return $this->getWrapperStorage()->file_get_contents($path);
@@ -294,7 +294,7 @@ public function copy($path1, $path2) {
*
* @param string $path
* @param string $mode
- * @return resource
+ * @return resource|bool
*/
public function fopen($path, $mode) {
return $this->getWrapperStorage()->fopen($path, $mode);
@@ -305,7 +305,7 @@ public function fopen($path, $mode) {
* The mimetype for a folder is required to be "httpd/unix-directory"
*
* @param string $path
- * @return string
+ * @return string|bool
*/
public function getMimeType($path) {
return $this->getWrapperStorage()->getMimeType($path);
@@ -317,7 +317,7 @@ public function getMimeType($path) {
* @param string $type
* @param string $path
* @param bool $raw
- * @return string
+ * @return string|bool
*/
public function hash($type, $path, $raw = false) {
return $this->getWrapperStorage()->hash($type, $path, $raw);
@@ -327,7 +327,7 @@ public function hash($type, $path, $raw = false) {
* see https://www.php.net/manual/en/function.free_space.php
*
* @param string $path
- * @return int
+ * @return int|bool
*/
public function free_space($path) {
return $this->getWrapperStorage()->free_space($path);
@@ -337,7 +337,7 @@ public function free_space($path) {
* search for occurrences of $query in file names
*
* @param string $query
- * @return array
+ * @return array|bool
*/
public function search($query) {
return $this->getWrapperStorage()->search($query);
@@ -360,7 +360,7 @@ public function touch($path, $mtime = null) {
* The local version of the file can be temporary and doesn't have to be persistent across requests
*
* @param string $path
- * @return string
+ * @return string|bool
*/
public function getLocalFile($path) {
return $this->getWrapperStorage()->getLocalFile($path);
@@ -458,7 +458,7 @@ public function getStorageCache() {
* get the ETag for a file or folder
*
* @param string $path
- * @return string
+ * @return string|bool
*/
public function getETag($path) {
return $this->getWrapperStorage()->getETag($path);
@@ -513,7 +513,7 @@ public function __call($method, $args) {
* For now the returned array can hold the parameter url - in future more attributes might follow.
*
* @param string $path
- * @return array
+ * @return array|bool
*/
public function getDirectDownload($path) {
return $this->getWrapperStorage()->getDirectDownload($path);
diff --git a/lib/private/Files/Stream/Encryption.php b/lib/private/Files/Stream/Encryption.php
index 577d1554101c0..5f6d8cde62189 100644
--- a/lib/private/Files/Stream/Encryption.php
+++ b/lib/private/Files/Stream/Encryption.php
@@ -34,6 +34,8 @@
use Icewind\Streams\Wrapper;
use OC\Encryption\Exceptions\EncryptionHeaderKeyExistsException;
+use function is_array;
+use function stream_context_create;
class Encryption extends Wrapper {
@@ -192,15 +194,20 @@ public static function wrap($source, $internalPath, $fullPath, array $header,
*
* @param resource $source
* @param string $mode
- * @param resource $context
- * @param string $protocol
- * @param string $class
+ * @param resource|array $context
+ * @param string|null $protocol
+ * @param string|null $class
* @return resource
* @throws \BadMethodCallException
*/
- protected static function wrapSource($source, $context, $protocol, $class, $mode = 'r+') {
+ protected static function wrapSource($source, $context = [], $protocol = null, $class = null, $mode = 'r+') {
try {
+ if ($protocol === null) {
+ $protocol = self::getProtocol($class);
+ }
+
stream_wrapper_register($protocol, $class);
+ $context = self::buildContext($protocol, $context, $source);
if (self::isDirectoryHandle($source)) {
$wrapped = opendir($protocol . '://', $context);
} else {
@@ -214,14 +221,26 @@ protected static function wrapSource($source, $context, $protocol, $class, $mode
return $wrapped;
}
+ /**
+ * @todo this is a copy of \Icewind\Streams\WrapperHandler::buildContext -> combine to one shared method?
+ */
+ private static function buildContext($protocol, $context, $source) {
+ if (is_array($context)) {
+ $context['source'] = $source;
+ return stream_context_create([$protocol => $context]);
+ }
+
+ return $context;
+ }
+
/**
* Load the source from the stream context and return the context options
*
- * @param string $name
+ * @param string|null $name
* @return array
* @throws \BadMethodCallException
*/
- protected function loadContext($name) {
+ protected function loadContext($name = null) {
$context = parent::loadContext($name);
foreach ($this->expectedContextProperties as $property) {
@@ -314,7 +333,7 @@ public function stream_read($count) {
}
return $result;
}
-
+
/**
* stream_read_block
*
diff --git a/lib/private/Repair/Owncloud/MoveAvatarsBackgroundJob.php b/lib/private/Repair/Owncloud/MoveAvatarsBackgroundJob.php
index e69beae7d6e2a..a4209d70df519 100644
--- a/lib/private/Repair/Owncloud/MoveAvatarsBackgroundJob.php
+++ b/lib/private/Repair/Owncloud/MoveAvatarsBackgroundJob.php
@@ -30,6 +30,7 @@
use OCP\IUser;
use OCP\IUserManager;
use Psr\Log\LoggerInterface;
+use function is_resource;
class MoveAvatarsBackgroundJob extends QueuedJob {
@@ -76,7 +77,7 @@ private function moveAvatars(): void {
try {
$avatarPath = $path . '/avatar.' . $this->getExtension($path);
$resource = $this->owncloudAvatarStorage->fopen($avatarPath, 'r');
- if ($resource) {
+ if (is_resource($resource)) {
$avatar->set($resource);
fclose($resource);
} else {
diff --git a/lib/public/Files/SimpleFS/ISimpleFile.php b/lib/public/Files/SimpleFS/ISimpleFile.php
index 06039d5397db5..ad39460c4bfe8 100644
--- a/lib/public/Files/SimpleFS/ISimpleFile.php
+++ b/lib/public/Files/SimpleFS/ISimpleFile.php
@@ -114,7 +114,7 @@ public function read();
/**
* Open the file as stream for writing, resulting resource can be operated as stream like the result from php's own fopen
*
- * @return resource
+ * @return resource|bool
* @throws \OCP\Files\NotPermittedException
* @since 14.0.0
*/
diff --git a/lib/public/Files/Storage.php b/lib/public/Files/Storage.php
index 2033fe5d28aa7..82f96f805dc48 100644
--- a/lib/public/Files/Storage.php
+++ b/lib/public/Files/Storage.php
@@ -92,7 +92,7 @@ public function rmdir($path);
* see https://www.php.net/manual/en/function.opendir.php
*
* @param string $path
- * @return resource|false
+ * @return resource|bool
* @since 6.0.0
*/
public function opendir($path);
@@ -120,7 +120,7 @@ public function is_file($path);
* only the following keys are required in the result: size and mtime
*
* @param string $path
- * @return array|false
+ * @return array|bool
* @since 6.0.0
*/
public function stat($path);
@@ -129,7 +129,7 @@ public function stat($path);
* see https://www.php.net/manual/en/function.filetype.php
*
* @param string $path
- * @return string|false
+ * @return string|bool
* @since 6.0.0
*/
public function filetype($path);
@@ -139,7 +139,7 @@ public function filetype($path);
* The result for filesize when called on a folder is required to be 0
*
* @param string $path
- * @return int|false
+ * @return int|bool
* @since 6.0.0
*/
public function filesize($path);
@@ -212,7 +212,7 @@ public function file_exists($path);
* see https://www.php.net/manual/en/function.filemtime.php
*
* @param string $path
- * @return int|false
+ * @return int|bool
* @since 6.0.0
*/
public function filemtime($path);
@@ -221,7 +221,7 @@ public function filemtime($path);
* see https://www.php.net/manual/en/function.file_get_contents.php
*
* @param string $path
- * @return string|false
+ * @return string|bool
* @since 6.0.0
*/
public function file_get_contents($path);
@@ -270,7 +270,7 @@ public function copy($path1, $path2);
*
* @param string $path
* @param string $mode
- * @return resource|false
+ * @return resource|bool
* @since 6.0.0
*/
public function fopen($path, $mode);
@@ -280,7 +280,7 @@ public function fopen($path, $mode);
* The mimetype for a folder is required to be "httpd/unix-directory"
*
* @param string $path
- * @return string|false
+ * @return string|bool
* @since 6.0.0
*/
public function getMimeType($path);
@@ -291,7 +291,7 @@ public function getMimeType($path);
* @param string $type
* @param string $path
* @param bool $raw
- * @return string|false
+ * @return string|bool
* @since 6.0.0
*/
public function hash($type, $path, $raw = false);
@@ -300,7 +300,7 @@ public function hash($type, $path, $raw = false);
* see https://www.php.net/manual/en/function.free_space.php
*
* @param string $path
- * @return int|false
+ * @return int|bool
* @since 6.0.0
*/
public function free_space($path);
@@ -309,7 +309,7 @@ public function free_space($path);
* search for occurrences of $query in file names
*
* @param string $query
- * @return array|false
+ * @return array|bool
* @since 6.0.0
*/
public function search($query);
@@ -330,7 +330,7 @@ public function touch($path, $mtime = null);
* The local version of the file can be temporary and doesn't have to be persistent across requests
*
* @param string $path
- * @return string|false
+ * @return string|bool
* @since 6.0.0
*/
public function getLocalFile($path);
@@ -352,7 +352,7 @@ public function hasUpdated($path, $time);
* get the ETag for a file or folder
*
* @param string $path
- * @return string|false
+ * @return string|bool
* @since 6.0.0
*/
public function getETag($path);
@@ -384,7 +384,7 @@ public function instanceOfStorage($class);
* For now the returned array can hold the parameter url - in future more attributes might follow.
*
* @param string $path
- * @return array|false
+ * @return array|bool
* @since 8.0.0
*/
public function getDirectDownload($path);
diff --git a/lib/public/Files/Storage/IStorage.php b/lib/public/Files/Storage/IStorage.php
index 0f5e3e5f30557..e93278684fd76 100644
--- a/lib/public/Files/Storage/IStorage.php
+++ b/lib/public/Files/Storage/IStorage.php
@@ -88,7 +88,7 @@ public function rmdir($path);
* see https://www.php.net/manual/en/function.opendir.php
*
* @param string $path
- * @return resource|false
+ * @return resource|bool
* @since 9.0.0
*/
public function opendir($path);
@@ -116,7 +116,7 @@ public function is_file($path);
* only the following keys are required in the result: size and mtime
*
* @param string $path
- * @return array|false
+ * @return array|bool
* @since 9.0.0
*/
public function stat($path);
@@ -125,7 +125,7 @@ public function stat($path);
* see https://www.php.net/manual/en/function.filetype.php
*
* @param string $path
- * @return string|false
+ * @return string|bool
* @since 9.0.0
*/
public function filetype($path);
@@ -135,7 +135,7 @@ public function filetype($path);
* The result for filesize when called on a folder is required to be 0
*
* @param string $path
- * @return int|false
+ * @return int|bool
* @since 9.0.0
*/
public function filesize($path);
@@ -208,7 +208,7 @@ public function file_exists($path);
* see https://www.php.net/manual/en/function.filemtime.php
*
* @param string $path
- * @return int|false
+ * @return int|bool
* @since 9.0.0
*/
public function filemtime($path);
@@ -217,7 +217,7 @@ public function filemtime($path);
* see https://www.php.net/manual/en/function.file_get_contents.php
*
* @param string $path
- * @return string|false
+ * @return string|bool
* @since 9.0.0
*/
public function file_get_contents($path);
@@ -266,7 +266,7 @@ public function copy($path1, $path2);
*
* @param string $path
* @param string $mode
- * @return resource|false
+ * @return resource|bool
* @since 9.0.0
*/
public function fopen($path, $mode);
@@ -276,7 +276,7 @@ public function fopen($path, $mode);
* The mimetype for a folder is required to be "httpd/unix-directory"
*
* @param string $path
- * @return string|false
+ * @return string|bool
* @since 9.0.0
*/
public function getMimeType($path);
@@ -287,7 +287,7 @@ public function getMimeType($path);
* @param string $type
* @param string $path
* @param bool $raw
- * @return string|false
+ * @return string|bool
* @since 9.0.0
*/
public function hash($type, $path, $raw = false);
@@ -296,7 +296,7 @@ public function hash($type, $path, $raw = false);
* see https://www.php.net/manual/en/function.free_space.php
*
* @param string $path
- * @return int|false
+ * @return int|bool
* @since 9.0.0
*/
public function free_space($path);
@@ -317,7 +317,7 @@ public function touch($path, $mtime = null);
* The local version of the file can be temporary and doesn't have to be persistent across requests
*
* @param string $path
- * @return string|false
+ * @return string|bool
* @since 9.0.0
*/
public function getLocalFile($path);
@@ -339,7 +339,7 @@ public function hasUpdated($path, $time);
* get the ETag for a file or folder
*
* @param string $path
- * @return string|false
+ * @return string|bool
* @since 9.0.0
*/
public function getETag($path);
@@ -371,7 +371,7 @@ public function instanceOfStorage($class);
* For now the returned array can hold the parameter url - in future more attributes might follow.
*
* @param string $path
- * @return array|false
+ * @return array|bool
* @since 9.0.0
*/
public function getDirectDownload($path);