Skip to content

Issue/541 Use back() in the shipped module templates - #624

Merged
armanist merged 3 commits into
quantum-php:masterfrom
armanist:issue/541-templates-back-redirect
Oct 27, 2026
Merged

armanist merged 3 commits into
quantum-php:masterfrom
armanist:issue/541-templates-back-redirect

Conversation

@armanist

Copy link
Copy Markdown
Collaborator

Closes #541.

What changed

  • The DemoWeb and Toolkit templates redirect back with back() instead of the manual referrer fallback:
    • redirect(get_referrer() ?? base_url()) becomes back() in DemoWeb CommentController (twice) and the Reset middleware, and in Toolkit DatabaseController and the CreateTable middleware.
    • redirectWith(get_referrer() ?? base_url(), $data) becomes back($data) in the DemoWeb Comment and Editor middlewares.
  • Added the Changed entry to CHANGELOG.md.

Why

#540 added back() and the back() helper, so generated code no longer needs to repeat the referrer fallback. The generated code also gets the same-origin check of back().

Breaking changes

None. Generated redirects behave as before for a same-origin referrer, and fall back to base_url() for an external one. Modules generated earlier keep their code.

Testing

New tests/Unit/Module/Templates/RedirectTemplatesTest.php, for the DemoWeb and Toolkit templates:

  • no template contains get_referrer() ?? base_url()
  • the templates redirect with return back(

Both checks fail on the templates before this change.

Notes for reviewers

  • Left unchanged on purpose: the redirects to a fixed target (redirect(base_url(true) . '/' . current_lang() . '/signin') and the redirectWith(...) ones), which back() cannot express, and the Guest middleware. Its fallback is base_url(true) . '/' . current_lang(), not base_url(), so back() would change its behavior.

armanist and others added 3 commits October 27, 2026 14:02
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@quantum-php quantum-php deleted a comment from coderabbitai Bot Oct 27, 2026
@codecov

codecov Bot commented Oct 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@armanist
armanist requested a review from artem-dev2 October 27, 2026 10:08
@armanist
armanist merged commit 29d9b20 into quantum-php:master Oct 27, 2026
7 checks passed
@armanist
armanist deleted the issue/541-templates-back-redirect branch October 27, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update shipped module templates to use the new response redirect API

3 participants