From 83e3a3c61460ba87b4f51c1c8a8d0b1c3e00ed50 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 --- .github/workflows/integration.yml | 11 ++++++----- lib/Service/CardService.php | 4 ++-- lib/Service/CommentService.php | 6 +----- lib/Service/PermissionService.php | 8 ++++++-- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 909473d22..508ed1481 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -69,16 +69,17 @@ jobs: path: apps/activity - name: Set up php ${{ matrix.php-versions }} - uses: shivammathur/setup-php@2.18.0 + uses: shivammathur/setup-php@2.25.4 with: php-version: ${{ matrix.php-versions }} - tools: phpunit - extensions: mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite, mysql, pdo_mysql, pgsql, pdo_pgsql, + extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite, mysql, pdo_mysql, pgsql, pdo_pgsql, apcu + ini-values: + apc.enable_cli=on coverage: none - - name: Set up PHPUnit + - name: Set up dependencies working-directory: apps/${{ env.APP_NAME }} - run: composer i + run: composer i --no-dev - name: Set up Nextcloud run: | diff --git a/lib/Service/CardService.php b/lib/Service/CardService.php index dc74a2fb2..62a9b55ab 100644 --- a/lib/Service/CardService.php +++ b/lib/Service/CardService.php @@ -1,4 +1,4 @@ -lib/Service/CardService.php * @@ -264,7 +264,7 @@ public function delete($id) { 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 @@ public function list(string $cardId, int $limit = 20, int $offset = 0): DataResp } /** - * @param string $cardId - * @param string $message - * @param string $replyTo - * @return DataResponse * @throws BadRequestException * @throws NotFoundException|NoPermissionException */ @@ -142,7 +138,7 @@ public function update(string $cardId, string $commentId, string $message): Data 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..0a6a7432c 100644 --- a/lib/Service/PermissionService.php +++ b/lib/Service/PermissionService.php @@ -98,7 +98,11 @@ public function __construct( * @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; } @@ -169,7 +173,7 @@ public function checkPermission($mapper, $id, $permission, $userId = null, bool } try { - $acls = $this->getBoard($boardId)->getAcl() ?? []; + $acls = $this->getBoard((int)$boardId)->getAcl() ?? []; $result = $this->userCan($acls, $permission, $userId); if ($result) { return true;