From f23d057ad92d77cbfeda9eed65a4874dc570761e Mon Sep 17 00:00:00 2001 From: Richard de Boer Date: Sat, 10 Apr 2021 14:49:13 +0200 Subject: [PATCH 1/3] Fix functions taking optional parameters before required ones PHP 8 shows deprecation warnings about this, see #25806 Removes the "default" values, as they actually are required parameters anyway. Signed-off-by: Richard de Boer --- apps/files/lib/Helper.php | 2 +- core/Controller/PreviewController.php | 4 ++-- lib/private/Files/Config/CachedMountFileInfo.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/files/lib/Helper.php b/apps/files/lib/Helper.php index 699caec59e..5ed11bd866 100644 --- a/apps/files/lib/Helper.php +++ b/apps/files/lib/Helper.php @@ -217,7 +217,7 @@ class Helper { * @param ITagManager $tagManager * @return array file list populated with tags */ - public static function populateTags(array $fileList, $fileIdentifier = 'fileid', ITagManager $tagManager) { + public static function populateTags(array $fileList, $fileIdentifier, ITagManager $tagManager) { $ids = []; foreach ($fileList as $fileData) { $ids[] = $fileData[$fileIdentifier]; diff --git a/core/Controller/PreviewController.php b/core/Controller/PreviewController.php index 0b76209408..d46ecc6d15 100644 --- a/core/Controller/PreviewController.php +++ b/core/Controller/PreviewController.php @@ -156,8 +156,8 @@ class PreviewController extends Controller { Node $node, int $x, int $y, - bool $a = false, - bool $forceIcon = true, + bool $a, + bool $forceIcon, string $mode) : Http\Response { if (!($node instanceof File) || (!$forceIcon && !$this->preview->isAvailable($node))) { return new DataResponse([], Http::STATUS_NOT_FOUND); diff --git a/lib/private/Files/Config/CachedMountFileInfo.php b/lib/private/Files/Config/CachedMountFileInfo.php index 7bae52bb65..1ca680e8a1 100644 --- a/lib/private/Files/Config/CachedMountFileInfo.php +++ b/lib/private/Files/Config/CachedMountFileInfo.php @@ -31,7 +31,7 @@ class CachedMountFileInfo extends CachedMountInfo implements ICachedMountFileInf /** @var string */ private $internalPath; - public function __construct(IUser $user, $storageId, $rootId, $mountPoint, $mountId = null, $rootInternalPath = '', $internalPath) { + public function __construct(IUser $user, $storageId, $rootId, $mountPoint, $mountId, $rootInternalPath, $internalPath) { parent::__construct($user, $storageId, $rootId, $mountPoint, $mountId, $rootInternalPath); $this->internalPath = $internalPath; } From a0d265b0b1b36e1d560e4c253b6596cdf137f637 Mon Sep 17 00:00:00 2001 From: Richard de Boer Date: Sat, 10 Apr 2021 14:50:17 +0200 Subject: [PATCH 2/3] Fix a usort comparison function returning a boolean instead of an integer PHP 8 shows deprecation warnings about this, see #25806 Signed-off-by: Richard de Boer --- .../AppFramework/Http/Template/PublicTemplateResponse.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/public/AppFramework/Http/Template/PublicTemplateResponse.php b/lib/public/AppFramework/Http/Template/PublicTemplateResponse.php index 84c940d422..58871caac2 100644 --- a/lib/public/AppFramework/Http/Template/PublicTemplateResponse.php +++ b/lib/public/AppFramework/Http/Template/PublicTemplateResponse.php @@ -97,7 +97,7 @@ class PublicTemplateResponse extends TemplateResponse { $this->headerActions[] = $action; } usort($this->headerActions, function (IMenuAction $a, IMenuAction $b) { - return $a->getPriority() > $b->getPriority(); + return $a->getPriority() <=> $b->getPriority(); }); } From 7990f95558ac2b7fac3b9f77dcbdc3c74b05785b Mon Sep 17 00:00:00 2001 From: Richard de Boer Date: Sat, 10 Apr 2021 15:05:18 +0200 Subject: [PATCH 3/3] Check whether output buffering is active before turning it off Before we just turned it off and @suppressed the error if ob was not active. In PHP 8 this error is no longer suppressed, so try to not cause it at all. Signed-off-by: Richard de Boer --- lib/private/Files/View.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index a59f735c10..8f4b5db116 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -422,7 +422,9 @@ class View { */ public function readfile($path) { $this->assertPathLength($path); - @ob_end_clean(); + if (ob_get_level()) { + ob_end_clean(); + } $handle = $this->fopen($path, 'rb'); if ($handle) { $chunkSize = 524288; // 512 kB chunks @@ -446,7 +448,9 @@ class View { */ public function readfilePart($path, $from, $to) { $this->assertPathLength($path); - @ob_end_clean(); + if (ob_get_level()) { + ob_end_clean(); + } $handle = $this->fopen($path, 'rb'); if ($handle) { $chunkSize = 524288; // 512 kB chunks