mirror of
https://github.com/nextcloud/server.git
synced 2026-04-21 06:08:46 -04:00
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>
This commit is contained in:
parent
5e96228eb1
commit
546d94c3ec
10 changed files with 16 additions and 13 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -564,7 +564,7 @@ class View {
|
|||
|
||||
/**
|
||||
* @param string $path
|
||||
* @return mixed
|
||||
* @return string|false
|
||||
* @throws LockedException
|
||||
*/
|
||||
public function file_get_contents($path) {
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ interface File extends Node {
|
|||
*
|
||||
* @return string
|
||||
* @throws NotPermittedException
|
||||
* @throws GenericFileException
|
||||
* @throws LockedException
|
||||
* @since 6.0.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ interface Storage extends IStorage {
|
|||
* see https://www.php.net/manual/en/function.file_get_contents.php
|
||||
*
|
||||
* @param string $path
|
||||
* @return string|bool
|
||||
* @return string|false
|
||||
* @since 6.0.0
|
||||
*/
|
||||
public function file_get_contents($path);
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ interface IStorage {
|
|||
* see https://www.php.net/manual/en/function.file_get_contents.php
|
||||
*
|
||||
* @param string $path
|
||||
* @return string|bool
|
||||
* @return string|false
|
||||
* @since 9.0.0
|
||||
*/
|
||||
public function file_get_contents($path);
|
||||
|
|
|
|||
Loading…
Reference in a new issue