Skip to content

Commit

Permalink
fix: PHP 7.4 compatibility
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Jan 9, 2024
1 parent 635880a commit 4e757bd
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions lib/Service/CardService.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
lib/Service/CardService.php<?php
<?php
/**
* @copyright Copyright (c) 2016 Julius Härtl <[email protected]>
*
Expand Down Expand Up @@ -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)) {
Expand Down
6 changes: 1 addition & 5 deletions lib/Service/CommentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions lib/Service/PermissionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/features/bootstrap/BoardContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class BoardContext implements Context {
private $storedCards = [];
private $activities = null;

private ServerContext $serverContext;
private $serverContext;

/** @BeforeScenario */
public function gatherContexts(BeforeScenarioScope $scope) {
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/features/bootstrap/ServerContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4e757bd

Please sign in to comment.