Properly handle if the related board cannot be found in mappers
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
namespace OCA\Deck\Db;
|
namespace OCA\Deck\Db;
|
||||||
|
|
||||||
|
use OCP\AppFramework\Db\DoesNotExistException;
|
||||||
|
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
||||||
use OCP\IDBConnection;
|
use OCP\IDBConnection;
|
||||||
|
|
||||||
class AclMapper extends DeckMapper implements IPermissionMapper {
|
class AclMapper extends DeckMapper implements IPermissionMapper {
|
||||||
@@ -43,8 +45,12 @@ class AclMapper extends DeckMapper implements IPermissionMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function findBoardId($aclId): ?int {
|
public function findBoardId($aclId): ?int {
|
||||||
|
try {
|
||||||
$entity = $this->find($aclId);
|
$entity = $this->find($aclId);
|
||||||
return $entity->getBoardId();
|
return $entity->getBoardId();
|
||||||
|
} catch (DoesNotExistException | MultipleObjectsReturnedException $e) {
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findByParticipant($type, $participant): array {
|
public function findByParticipant($type, $participant): array {
|
||||||
|
|||||||
@@ -322,8 +322,7 @@ class CardMapper extends QBMapper implements IPermissionMapper {
|
|||||||
$stmt = $this->db->prepare($sql);
|
$stmt = $this->db->prepare($sql);
|
||||||
$stmt->bindParam(1, $cardId, \PDO::PARAM_INT);
|
$stmt->bindParam(1, $cardId, \PDO::PARAM_INT);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$row = $stmt->fetch();
|
return $stmt->fetchColumn() ?? null;
|
||||||
return $row['id'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mapOwner(Card &$card) {
|
public function mapOwner(Card &$card) {
|
||||||
|
|||||||
@@ -23,7 +23,9 @@
|
|||||||
|
|
||||||
namespace OCA\Deck\Db;
|
namespace OCA\Deck\Db;
|
||||||
|
|
||||||
|
use OCP\AppFramework\Db\DoesNotExistException;
|
||||||
use OCP\AppFramework\Db\Entity;
|
use OCP\AppFramework\Db\Entity;
|
||||||
|
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
||||||
use OCP\IDBConnection;
|
use OCP\IDBConnection;
|
||||||
|
|
||||||
class LabelMapper extends DeckMapper implements IPermissionMapper {
|
class LabelMapper extends DeckMapper implements IPermissionMapper {
|
||||||
@@ -100,7 +102,12 @@ class LabelMapper extends DeckMapper implements IPermissionMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function findBoardId($labelId): ?int {
|
public function findBoardId($labelId): ?int {
|
||||||
|
try {
|
||||||
$entity = $this->find($labelId);
|
$entity = $this->find($labelId);
|
||||||
return $entity->getBoardId();
|
return $entity->getBoardId();
|
||||||
|
} catch (DoesNotExistException $e) {
|
||||||
|
} catch (MultipleObjectsReturnedException $e) {
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,9 @@
|
|||||||
|
|
||||||
namespace OCA\Deck\Db;
|
namespace OCA\Deck\Db;
|
||||||
|
|
||||||
|
use OCP\AppFramework\Db\DoesNotExistException;
|
||||||
use OCP\AppFramework\Db\Entity;
|
use OCP\AppFramework\Db\Entity;
|
||||||
|
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
||||||
use OCP\IDBConnection;
|
use OCP\IDBConnection;
|
||||||
|
|
||||||
class StackMapper extends DeckMapper implements IPermissionMapper {
|
class StackMapper extends DeckMapper implements IPermissionMapper {
|
||||||
@@ -75,7 +77,12 @@ class StackMapper extends DeckMapper implements IPermissionMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function findBoardId($stackId): ?int {
|
public function findBoardId($stackId): ?int {
|
||||||
|
try {
|
||||||
$entity = $this->find($stackId);
|
$entity = $this->find($stackId);
|
||||||
return $entity->getBoardId();
|
return $entity->getBoardId();
|
||||||
|
} catch (DoesNotExistException $e) {
|
||||||
|
} catch (MultipleObjectsReturnedException $e) {
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user