Skip to content

[stable5.4] fix: unify checks for deleted questions and don't load submissions to deleted questions - #4018

Merged
Chartman123 merged 1 commit into
stable5.4from
backport/4017/stable5.4
Nov 24, 2026
Merged

Chartman123 merged 1 commit into
stable5.4from
backport/4017/stable5.4

Conversation

@backportbot

@backportbot backportbot Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Backport of #4017

Warning, This backport's changes differ from the original and might be incomplete ⚠️

Todo

  • Review and resolve any conflicts
  • Review and verify the backported changes
  • Amend HEAD commit to remove the line stating to skip CI

Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports.

@backportbot backportbot Bot added bug Something isn't working 3. to review Waiting for reviews AI assisted labels Nov 24, 2026
… deleted questions

Signed-off-by: Christian Hartmann <chris-hartmann@gmx.de>

only file questions take uploads

Signed-off-by: Christian Hartmann <chris-hartmann@gmx.de>

test(question): expect the status of each endpoint for deleted questions

With deleted questions filtered in QuestionMapper::findById(), each
endpoint answers a deleted question like an unknown one: deleteOption
with 400, as it always did for an unknown question, and the others
with 404, so the expected exception is set per data set.

testUploadFiles now uploads for a file question, as uploads for other
question types are rejected, and a new test covers both rejections: a
short question (400) and a deleted file question (404).

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>

fix(api): document the rejected question type of an upload as @throws

The tag was spelled @htrows, so the OpenAPI extractor took the line for
part of the endpoint description instead of a documented response.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>

fix(submission): leave answers to deleted questions out of the search

The results list and the export no longer show answers to deleted
questions, but the search still matched them, so a search for a word
that only appears in such an answer returned the submission without
any visible match. The search now joins the questions and only matches
answers to questions that are not deleted, for the list and the count
alike.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>

perf(submission): look up the active questions of answers by key

Each answer was checked with in_array against all question ids of the
form, which grows with answers times questions on every results load
and export. The ids are now keys of an array, and the export reuses the
id list it builds for the options anyway.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>

fix(api): answer a missing option or question of deleteOption with 404

deleteOption documents "Could not find question or option" as a 404,
like updateOption, but threw a 400. With deleted questions filtered in
QuestionMapper::findById(), a deleted question would also have changed
from 404 to 400 there; now all option and question endpoints answer a
deleted or unknown question with 404.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>

refactor(question): always skip deleted questions in findById

No caller loads a deleted question by id, so the loadDeleted option goes,
and an integration test checks against the database that findById finds
an active question and skips a deleted one, which every endpoint now
relies on.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>

refactor(submission): build the lookup of active questions in one place

getSubmissionsData built the same id lookup as the helper next to it.
The helper now takes the questions, so all three callers share it, and
the comments that repeated the code are gone.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>

refactor(submission): take the questions table of the search from its mapper

The search joined the answers table through its mapper but the
questions table by a literal name.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>

test(question): drop the unused deleted questions of the rejection tests

findById() is mocked to throw in these tests, so the question objects
with order 0 they built were never read.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>

docs(api): describe the responses for deleted questions and non-file uploads

Reordering with a deleted question and deleting an option of a deleted
question now answer with Not Found, an upload for a question that is not
a file question with Bad Request, and submissions, search and exports
leave out answers to deleted questions.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>

docs(question): state that findById does not find deleted questions

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>

refactor(submission): require the active questions when reading answers

The only caller of getAnswers always passes them, so the optional null
case never ran. The confirmation email test uses the imported
DoesNotExistException like the rest of the file.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>

test(question): reject deleted and unknown questions on every endpoint

The controller unit tests mock findById(), where a deleted and an unknown
question look the same. Against the database, the API now gets a deleted
question (deleted through the API first) and an id that does not exist
on every question and option endpoint and on the upload, and expects
404 for both; an upload for a short question gets 400. The mapper test
covers an unknown id next to an active and a deleted question.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>

Signed-off-by: Christian Hartmann <chris-hartmann@gmx.de>
@Chartman123
Chartman123 force-pushed the backport/4017/stable5.4 branch from cbba1c0 to e98f47f Compare November 24, 2026 22:07
@Chartman123
Chartman123 marked this pull request as ready for review November 24, 2026 22:07
@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.00000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
lib/Controller/ApiController.php 83.33% 1 Missing ⚠️
lib/Service/SubmissionService.php 94.11% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Chartman123
Chartman123 merged commit b0bb0f8 into stable5.4 Nov 24, 2026
52 checks passed
@Chartman123
Chartman123 deleted the backport/4017/stable5.4 branch November 24, 2026 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews AI assisted bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant