summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2023-04-27 09:56:05 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2023-04-27 09:56:05 +0200
commit546d94c3ec5b0cb06cc284dead0da98ee346fc81 (patch)
treef64015e26506776e16ce679e61f4e8571e92b7af /lib/private
parent5e96228eb1f7999a327dacab22055ec2aa8e28a3 (diff)
downloadnextcloud-server-546d94c3ec5b0cb06cc284dead0da98ee346fc81.tar.gz
nextcloud-server-546d94c3ec5b0cb06cc284dead0da98ee346fc81.zip
Fix file_get_content signatures to make it clear it can return false
In File::getContent, which must return a string, throw an Exception instead of returning false. Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Files/Filesystem.php2
-rw-r--r--lib/private/Files/Node/File.php12
-rw-r--r--lib/private/Files/Storage/Wrapper/Encoding.php2
-rw-r--r--lib/private/Files/Storage/Wrapper/Encryption.php2
-rw-r--r--lib/private/Files/Storage/Wrapper/Jail.php2
-rw-r--r--lib/private/Files/Storage/Wrapper/Wrapper.php2
-rw-r--r--lib/private/Files/View.php2
7 files changed, 13 insertions, 11 deletions
diff --git a/lib/private/Files/Filesystem.php b/lib/private/Files/Filesystem.php
index c50fa1f9de9..2eab4c58a0c 100644
--- a/lib/private/Files/Filesystem.php
+++ b/lib/private/Files/Filesystem.php
@@ -554,7 +554,7 @@ class Filesystem {
}
/**
- * @return string
+ * @return string|false
*/
public static function file_get_contents($path) {
return self::$defaultInstance->file_get_contents($path);
diff --git a/lib/private/Files/Node/File.php b/lib/private/Files/Node/File.php
index 27056efef72..b6cd6571651 100644
--- a/lib/private/Files/Node/File.php
+++ b/lib/private/Files/Node/File.php
@@ -46,14 +46,16 @@ class File extends Node implements \OCP\Files\File {
/**
* @return string
* @throws NotPermittedException
+ * @throws GenericFileException
* @throws LockedException
*/
public function getContent() {
if ($this->checkPermissions(\OCP\Constants::PERMISSION_READ)) {
- /**
- * @var \OC\Files\Storage\Storage $storage;
- */
- return $this->view->file_get_contents($this->path);
+ $content = $this->view->file_get_contents($this->path);
+ if ($content === false) {
+ throw new GenericFileException();
+ }
+ return $content;
} else {
throw new NotPermittedException();
}
@@ -62,7 +64,7 @@ class File extends Node implements \OCP\Files\File {
/**
* @param string|resource $data
* @throws NotPermittedException
- * @throws \OCP\Files\GenericFileException
+ * @throws GenericFileException
* @throws LockedException
*/
public function putContent($data) {
diff --git a/lib/private/Files/Storage/Wrapper/Encoding.php b/lib/private/Files/Storage/Wrapper/Encoding.php
index dd699993e84..6633cbf41e3 100644
--- a/lib/private/Files/Storage/Wrapper/Encoding.php
+++ b/lib/private/Files/Storage/Wrapper/Encoding.php
@@ -300,7 +300,7 @@ class Encoding extends Wrapper {
* see https://www.php.net/manual/en/function.file_get_contents.php
*
* @param string $path
- * @return string|bool
+ * @return string|false
*/
public function file_get_contents($path) {
return $this->storage->file_get_contents($this->findPathToUse($path));
diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php
index 720111793de..9c0e6c91463 100644
--- a/lib/private/Files/Storage/Wrapper/Encryption.php
+++ b/lib/private/Files/Storage/Wrapper/Encryption.php
@@ -217,7 +217,7 @@ class Encryption extends Wrapper {
* see https://www.php.net/manual/en/function.file_get_contents.php
*
* @param string $path
- * @return string
+ * @return string|false
*/
public function file_get_contents($path) {
$encryptionModule = $this->getEncryptionModule($path);
diff --git a/lib/private/Files/Storage/Wrapper/Jail.php b/lib/private/Files/Storage/Wrapper/Jail.php
index 619d8b07137..caf039d4cca 100644
--- a/lib/private/Files/Storage/Wrapper/Jail.php
+++ b/lib/private/Files/Storage/Wrapper/Jail.php
@@ -248,7 +248,7 @@ class Jail extends Wrapper {
* see https://www.php.net/manual/en/function.file_get_contents.php
*
* @param string $path
- * @return string|bool
+ * @return string|false
*/
public function file_get_contents($path) {
return $this->getWrapperStorage()->file_get_contents($this->getUnjailedPath($path));
diff --git a/lib/private/Files/Storage/Wrapper/Wrapper.php b/lib/private/Files/Storage/Wrapper/Wrapper.php
index 28a1e0b1e4d..9f5564b4490 100644
--- a/lib/private/Files/Storage/Wrapper/Wrapper.php
+++ b/lib/private/Files/Storage/Wrapper/Wrapper.php
@@ -238,7 +238,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage, IWriteStrea
* see https://www.php.net/manual/en/function.file_get_contents.php
*
* @param string $path
- * @return string|bool
+ * @return string|false
*/
public function file_get_contents($path) {
return $this->getWrapperStorage()->file_get_contents($path);
diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php
index 91e6cc2d60e..5970c213210 100644
--- a/lib/private/Files/View.php
+++ b/lib/private/Files/View.php
@@ -564,7 +564,7 @@ class View {
/**
* @param string $path
- * @return mixed
+ * @return string|false
* @throws LockedException
*/
public function file_get_contents($path) {