Repository navigation
[stable5.4] fix: unify checks for deleted questions and don't load submissions to deleted questions - #4018
Merged
Conversation
… 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
force-pushed
the
backport/4017/stable5.4
branch
from
November 24, 2026 22:07
cbba1c0 to
e98f47f
Compare
Chartman123
marked this pull request as ready for review
November 24, 2026 22:07
Chartman123
approved these changes
Nov 24, 2026
Chartman123
enabled auto-merge
November 24, 2026 22:08
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #4017
Warning, This backport's changes differ from the original and might be incomplete⚠️
Todo
Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports.