Problem/Motivation
Drupal now includes inbuilt Fast404 support controlled by a hidden system setting. This includes an option to exclude some paths from triggering a 404: this defaults to '/\/(?:styles|imagecache)\//' (excluding image cache generated images from the fast 404). Should you not want to exclude these paths and set the setting to empty, the Fast404 system is disabled for all paths.
Steps to reproduce
In system.performance.yml set the exclude_paths option to empty and import config. Visit a path that should trigger a Fast404 response: the standard Drupal 404 page will display.
Proposed resolution
The code in Fast404ExceptionHtmlSubscriber.php::on404() includes the line:
if ($config->get('fast_404.enabled') && $exclude_paths && !preg_match($exclude_paths, $request->getPathInfo())) {
This means that the $exclude_paths variable must be set - from $config->get('fast_404.exclude_paths'); - before the code that checks whether the current path is one that should trigger a Fast404: if it isn't set, no code runs and the standard 404 is returned.
Is there some reason I'm not aware of that we shouldn't generate Fast404s for image cache image styles?
Comments
Comment #2
cilefen commented@mrdalesmith
Could you please let me know if this issue is more suited to be a bug report? It's marked as a feature request, but it seems more like a bug: even an empty
exclude_pathsstring disables the fast 404 system because of that boolean expression.To answer your question, #1934716: [Followup] Merge system.fast_404 config object into system.performance introduced
imagecacheto that configuration with little discussion.Comment #3
cilefen commentedComment #4
cilefen commentedThe
stylesdefault exclusion dates to #76824: Drupal should not handle 404 for certain files.Comment #5
mrdalesmith commentedAh: looking at the history of it I see why the image_cache directories are excluded: it's receiving a 404 on an image derivative that makes Drupal generate it, in't it?
I couldn't say whether this is a bug because the code specifically looks for the exclude paths being set and there may have been a reason for that. Which I think it looks like there is. However, I think that either the styles|image_cache folders should be hardcoded as excluded and optional additional paths to exclude added via the current setting, or if Drupal allows that value to be unset it shouldn't also disable the Fast404: if the code says a site owner has control over what paths are excluded, that should probably be respected.
Comment #6
cilefen commented