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:
Julius Härtl
2020-11-13 12:03:05 +01:00
parent 4549a2b0ee
commit 2de43a6725
4 changed files with 27 additions and 8 deletions

View File

@@ -23,7 +23,9 @@
namespace OCA\Deck\Db;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\Entity;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use OCP\IDBConnection;
class StackMapper extends DeckMapper implements IPermissionMapper {
@@ -75,7 +77,12 @@ class StackMapper extends DeckMapper implements IPermissionMapper {
}
public function findBoardId($stackId): ?int {
$entity = $this->find($stackId);
return $entity->getBoardId();
try {
$entity = $this->find($stackId);
return $entity->getBoardId();
} catch (DoesNotExistException $e) {
} catch (MultipleObjectsReturnedException $e) {
}
return null;
}
}