Redirect to 404 Page for Invalid Image Paths

Created on 6 June 2024, 7 months ago
Updated 27 June 2024, 6 months ago

The drimage_improved module currently does not properly handle requests for invalid or non-existing image paths. When a user requests an image path that does not correspond to an existing file, the module should log an error and redirect the user to the standard 404 error page.

Steps to Reproduce
Enable the drimage_improved module.
Request an image URL with an invalid path or a non-existing file.
Observe that the module does not redirect to a 404 page or log the error as expected it gives a fatal error
Call to a member function id() on bool
/modules/contrib/drimage_improved/src/EventSubscriber/DrimageSubscriber.php in Drupal\drimage_improved\EventSubscriber\DrimageSubscriber::onKernelRequest at line 134

Expected Behavior
The module should log an error message with the full requested URL.
The user should be redirected to the standard 404 error page.
Proposed Solution
Modify the onKernelRequest method in the DrimageSubscriber class to:
Log an error message with the full requested URL when the file entity is not found.
Redirect the user to the 404 error page.

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇯🇴Jordan Qusai Taha Amman

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

Comments & Activities

Production build 0.71.5 2024