Skip to content

Commit 76b1260

Browse files
committed
fixes for Lint and Unit Tests
Signed-off-by: Timotheus Pokorra <timotheus.pokorra@solidcharity.com>
1 parent 5a81f1f commit 76b1260

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

lib/Service/FormsService.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public function getOptions(int $questionId): array {
150150
}
151151
}
152152

153-
private function getAnswers(int $formId, int $submissionId, string $userId): array|false {
153+
private function getAnswers(int $formId, int $submissionId, string $userId): array {
154154

155155
$answerList = [];
156156
$answerEntities = $this->answerMapper->findBySubmission($submissionId);
@@ -230,18 +230,20 @@ public function getForm(int $id): array {
230230
$result['questions'] = $this->getQuestions($id);
231231

232232
// add previous submission if there is one by this user for this form
233-
if ($this->currentUser->getUID()) {
233+
if ($this->currentUser->getUID() && form->getAllowEdit()) {
234234
$submissionEntity = null;
235235
try {
236236
$submissionEntity = $this->submissionMapper->findByFormAndUser($id, $this->currentUser->getUID());
237237
$answers = $this->getAnswers($id, $submissionEntity->getId(), $this->currentUser->getUID());
238-
if ($answers !== false) {
238+
if (!empty($answers)) {
239239
$result['answers'] = $answers;
240240
$result['newSubmission'] = false;
241241
$result['submissionId'] = $submissionEntity->getId();
242242
}
243243
} catch (DoesNotExistException $e) {
244244
// do nothing
245+
} catch (MultipleObjectsReturnedException $e) {
246+
// do nothing
245247
}
246248
}
247249

0 commit comments

Comments
 (0)