Skip to content

ignore page revision parameter when page id is 404 - #460

Merged
ilaria-orlando merged 1 commit into
masterfrom
fix-page-revision-404
Oct 29, 2026
Merged

ilaria-orlando merged 1 commit into
masterfrom
fix-page-revision-404

Conversation

@ilaria-orlando

@ilaria-orlando ilaria-orlando commented Oct 29, 2026 •

Copy link
Copy Markdown

Type

  • Non critical bugfix

Resolves the following issues

A request with a page_revision parameter that doesn't match an existing revision results in an uncaught
NotFoundHttpException ("No page was found for the page id:404") instead of the regular 404 page.

Pull request description

Cause

Page::getPageRecord() ignores $pageId when page_revision is present in the URL and loads that revision instead:

  1. Page::load() calls handlePage() with the page id from the URL.
  2. getPageRecord() sees page_revision and loads the revision. It doesn't exist, so handlePage() throws a
    NotFoundHttpException.
  3. load() catches it and retries with handlePage(404) to render the 404 page.
  4. page_revision is still in the URL, so getPageRecord() ignores the 404 id again and looks up the same
    non-existing revision.
  5. handlePage() throws a second NotFoundHttpException. This one happens inside the catch block, so nothing
    catches it.

Fix

Skip the revision lookup when the 404 page itself gets loaded, so the fallback always uses the regular 404 page

Summary by Sourcery

Bug Fixes:

  • Ensure requests for a missing page with an invalid page revision render the regular 404 page instead of raising an uncaught exception.

@sourcery-ai

sourcery-ai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Fixes uncaught errors during 404 fallback by making the page loader ignore page_revision when loading page ID 404, while preserving revision handling for regular pages.

Sequence diagram for page revision 404 fallback

sequenceDiagram
    participant Request
    participant Page
    participant Model

    Request->>Page: load()
    Page->>Page: handlePage(pageId)
    Page->>Page: getPageRecord(pageId)
    alt page_revision exists and pageId is not 404
        Page->>Model: load page revision
        Model-->>Page: revision not found
        Page-->>Page: throw NotFoundHttpException
        Page->>Page: handlePage(404)
    else pageId is 404
        Page->>Model: getPage(404)
        Model-->>Page: 404 page record
        Page-->>Request: render regular 404 page
    end
Loading

File-Level Changes

Change Details Files
Ensure the 404 fallback loads the configured 404 page instead of attempting to resolve an invalid revision.
  • Bypass page_revision lookup when the requested page ID is 404.
  • Continue using the normal page lookup for non-404 requests and revision-aware requests.
src/Frontend/Core/Engine/Page.php

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@ilaria-orlando
ilaria-orlando merged commit db57305 into master Oct 29, 2026
9 of 12 checks passed
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.

3 participants