From 16e5b36d2fd7634c5407dce8b9b286794caebb1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Tue, 9 Jan 2024 18:08:53 +0100 Subject: [PATCH] fix: PHP 7.4 compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/Service/CardService.php | 4 ++-- lib/Service/CommentService.php | 6 +----- lib/Service/PermissionService.php | 10 +++++++--- tests/integration/features/bootstrap/BoardContext.php | 2 +- tests/integration/features/bootstrap/ServerContext.php | 6 +++--- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/Service/CardService.php b/lib/Service/CardService.php index 909154166..58861df84 100644 --- a/lib/Service/CardService.php +++ b/lib/Service/CardService.php @@ -1,4 +1,4 @@ -lib/Service/CardService.php * @@ -264,7 +264,7 @@ class CardService { public function update($id, $title, $stackId, $type, $owner, $description = '', $order = 0, $duedate = null, $deletedAt = null, $archived = null) { $this->cardServiceValidator->check(compact('id', 'title', 'stackId', 'type', 'owner', 'order')); - $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT, allowDeletedCard: true); + $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT, null, true); $this->permissionService->checkPermission($this->stackMapper, $stackId, Acl::PERMISSION_EDIT); if ($this->boardService->isArchived($this->cardMapper, $id)) { diff --git a/lib/Service/CommentService.php b/lib/Service/CommentService.php index d15c7cc88..5f47e0893 100644 --- a/lib/Service/CommentService.php +++ b/lib/Service/CommentService.php @@ -83,10 +83,6 @@ class CommentService { } /** - * @param string $cardId - * @param string $message - * @param string $replyTo - * @return DataResponse * @throws BadRequestException * @throws NotFoundException|NoPermissionException */ @@ -142,7 +138,7 @@ class CommentService { throw new NoPermissionException('Only authors are allowed to edit their comment.'); } if ($comment->getParentId() !== '0') { - $this->permissionService->checkPermission($this->cardMapper, $comment->getParentId(), Acl::PERMISSION_READ); + $this->permissionService->checkPermission($this->cardMapper, (int)$comment->getParentId(), Acl::PERMISSION_READ); } $comment->setMessage($message); diff --git a/lib/Service/PermissionService.php b/lib/Service/PermissionService.php index 48d6af96d..5fd657c37 100644 --- a/lib/Service/PermissionService.php +++ b/lib/Service/PermissionService.php @@ -98,7 +98,11 @@ class PermissionService { * @param $boardId * @return bool|array */ - public function getPermissions($boardId) { + public function getPermissions($boardId, ?string $userId = null) { + if ($userId === null) { + $userId = $this->userId; + } + if ($cached = $this->permissionCache->get($boardId)) { return $cached; } @@ -113,7 +117,7 @@ class PermissionService { Acl::PERMISSION_SHARE => ($owner || $this->userCan($acls, Acl::PERMISSION_SHARE)) && (!$this->shareManager->sharingDisabledForUser($this->userId)) ]; - $this->permissionCache->set($boardId, $permissions); + $this->permissionCache->set((string)$boardId, $permissions); return $permissions; } @@ -169,7 +173,7 @@ class PermissionService { } try { - $acls = $this->getBoard($boardId)->getAcl() ?? []; + $acls = $this->getBoard((int)$boardId)->getAcl() ?? []; $result = $this->userCan($acls, $permission, $userId); if ($result) { return true; diff --git a/tests/integration/features/bootstrap/BoardContext.php b/tests/integration/features/bootstrap/BoardContext.php index 315aa8bcf..d0484a52b 100644 --- a/tests/integration/features/bootstrap/BoardContext.php +++ b/tests/integration/features/bootstrap/BoardContext.php @@ -19,7 +19,7 @@ class BoardContext implements Context { private $storedCards = []; private $activities = null; - private ServerContext $serverContext; + private $serverContext; /** @BeforeScenario */ public function gatherContexts(BeforeScenarioScope $scope) { diff --git a/tests/integration/features/bootstrap/ServerContext.php b/tests/integration/features/bootstrap/ServerContext.php index 6ed36f320..b10429b61 100644 --- a/tests/integration/features/bootstrap/ServerContext.php +++ b/tests/integration/features/bootstrap/ServerContext.php @@ -10,9 +10,9 @@ class ServerContext implements Context { WebDav::__construct as private __tConstruct; } - private string $rawBaseUrl; - private string $mappedUserId; - private array $lastInsertIds = []; + private $rawBaseUrl; + private $mappedUserId; + private $lastInsertIds = []; public function __construct($baseUrl) { $this->rawBaseUrl = $baseUrl;