Some of exceptions thrown by route enhancer should not be ignored

Created on 28 March 2022, over 2 years ago
Updated 13 March 2023, almost 2 years ago

Problem/Motivation

If Drupal fails to write cache or something in a certain point, Page Manager returns 404 page, instead of 5xx error.
It is because that \Drupal\page_manager\Routing\VariantRouteFilter catches and ignores all \Exceptions thrown by route enhancers.

try {
  $attributes = $enhancer->enhance($attributes, $request);
}
catch (\Exception $e) {
  return FALSE;
}

DB errors should be reported as 5xx errors, not Not Found. This can be a serious problem if the site has a cache server. In our case, the cache server cached 404 responses, and then end-users could not access some existing pages. If 5xx status codes had been returned, it would have been just temporal errors due to high load.

Steps to reproduce

  1. Install Drupal 9.3.
  2. Install Page Manager 8.x-4.0-beta6.
  3. Create a Page and a Page Variant.
  4. Implement a custom route enhancer which internally throws \Drupal\Core\Database\DatabaseException. (TODO: I will add such classes as test cases.)
  5. Access the page created at step 3.
  6. 404 Not Found

Proposed resolution

Catch and re-throw \PDOException, DatabaseException and TempStoreException thrown by route enhancers.

Remaining tasks

  • Add tests
  • Review patch

User interface changes

None

API changes

None

Data model changes

None

🐛 Bug report
Status

Needs work

Component

Code

Created by

🇯🇵Japan kensuke-imamura

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024