Add option to exclude all non whitelisted file paths (Performance)

Created on 16 May 2023, about 1 year ago
Updated 31 October 2023, 8 months ago

Problem/Motivation

See 🐛 Exclude fast_404 paths and file extensions by default (Performance) Postponed: needs info for details and where this point comes from

For performance reasons it might make sense to generally exclude all paths ending on a file extension not listed in the "Extensions to ignore" field to be excluded. not only the listed ones.

Steps to reproduce

Call file paths that don't exist for any file extensions, like

  • .css.map
  • .json
  • .webp
  • .svg
  • .md
  • \.*
  • ...

Proposed resolution

Add a checkbox / switch to "Disable on all paths with file extension". If enabled, the "Extensions to abort search" input field should be hidden and all paths ending on a non-whitelisted by "Extensions to ignore" field should not be handled.

Looking at the performance impacts of each of those non exiting file calls, now that 🐛 Fast 404s are slower than regular 404s Fixed has been committed in core, it might be worth to have this enabled by default and inform users to update their preferences when running the update hook.

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Fixed

Version

2.0

Component

Code

Created by

🇩🇪Germany Anybody Porta Westfalica

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

Comments & Activities

  • Issue created by @Anybody
  • 🇩🇪Germany Anybody Porta Westfalica
  • First commit to issue fork.
  • Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7 & MySQL 5.5
    last update about 1 year ago
    Waiting for branch to pass
  • @grevil opened merge request.
  • Status changed to Needs review about 1 year ago
  • Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7 & MySQL 5.5
    last update about 1 year ago
    Waiting for branch to pass
  • Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7 & MySQL 5.5
    last update about 1 year ago
    Waiting for branch to pass
  • Status changed to Needs work about 1 year ago
  • 🇩🇪Germany Anybody Porta Westfalica

    Great work once again @Grevil! Commented, please add tests for this afterwards to ensure:

    1. Regular and whitelisted queries are not blocked
    2. All file queries are blocked
    3. Existing behavior works as before (checkbox disabled)
  • 🇩🇪Germany Grevil

    Since there are no functional tests implemented for this module yet, I'd suggest we refer to the test issue, and create the tests there, after these fixes are committed to dev (preferably to a new SemVer Version), WITHOUT creating a new release until the tests are implemented there.

    Referring to 📌 Create tests to test this modules functionality Active .

  • Assigned to mitthukumawat
  • Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7 & MySQL 5.5
    last update 12 months ago
    Waiting for branch to pass
  • Issue was unassigned.
  • 🇮🇳India mitthukumawat

    I am reviewing the issue and find one problem. After enabling the Abort search on all paths containing file extensions checkbox, the file extension 404 showing Invalid keywords used..

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7 & MySQL 5.5
    last update 8 months ago
    Composer error. Unable to continue.
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7 & MySQL 5.5
    last update 8 months ago
    Composer error. Unable to continue.
  • Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7 & MySQL 5.5
    last update 8 months ago
    Waiting for branch to pass
  • Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7 & MySQL 5.5
    last update 8 months ago
    Waiting for branch to pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7 & MySQL 5.5
    last update 8 months ago
    Composer error. Unable to continue.
  • 🇩🇪Germany Grevil

    OK, for some reason, I didn't properly finish this MR. Thanks for the adjustments based on the comments by @Anybody @mitthukumawat!

    I did a rebase, added the missing update hook, and adjusted the logic, so if the search result ends with an ignored extension, the query will still execute (as stated in the "search404_ignore_file_queries" description: "[...] All extensions listed in "Extensions to ignore" will still be searched for [...]".

    After enabling the Abort search on all paths containing file extensions checkbox, the file extension 404 showing Invalid keywords used..

    Yes, this is correct, as it is the default message if the query gets aborted. So the logic works as expected, but the message doesn't make sense here, I agree! I'll adjust it accordingly!

  • Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7 & MySQL 5.5
    last update 8 months ago
    Waiting for branch to pass
  • Status changed to Needs review 8 months ago
  • 🇩🇪Germany Grevil

    Alright, I adjusted the error message, but I think the original error message 'The page you requested does not exist. Invalid keywords used.' might actually better... @Anybody should decide here.
    This is the error message now:

    We should also think about what priority "Extensions to ignore" (search404_ignore_extensions) should have. Currently, if "Abort search on all paths containing file extensions" (search404_ignore_file_queries) is enabled, the search will NOT abort if the query ends with an extension defined in "Extensions to ignore" (search404_ignore_extensions).
    This is part of the requirement of "Abort search on all paths containing file extensions", see its description:

    [...] All extensions listed in "Extensions to ignore" will still be searched for. [...]

    BUT if we disable "Abort search on all paths containing file extensions", we can manually define file extensions to abort search on, through the "Extensions to abort search" (search404_ignore_query) setting. This setting currently has a higher priority, then "Extensions to ignore", which could be a bit confusing, but it was programmed like this before.

    @Anybody, should we eventually program "Extensions to abort search" to be in line with "Abort search on all paths containing file extensions", so that the query never gets aborted, if the file extension is listed in "Extensions to ignore"?

    Otherwise everything is in line now, please review!

  • Status changed to Needs work 8 months ago
  • 🇩🇪Germany Anybody Porta Westfalica

    This is super confusing and we should first decide on the expected End-User-Experience (UX).
    Are we skipping file extensions in the background, or do we tell the user they did something forbidden?

    From reading the code it currently seems to be mixed-up and confusing what's the goal.

  • Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7 & MySQL 5.5
    last update 8 months ago
    Waiting for branch to pass
  • Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7 & MySQL 5.5
    last update 8 months ago
    Waiting for branch to pass
  • Status changed to Needs review 8 months ago
  • 🇩🇪Germany Grevil

    I'd say renaming the config names shouldn't be part of this issue. Your main issue probably came with the badly named error message. I adjusted it accordingly. A maintainer should review this and decide.

  • Status changed to RTBC 8 months ago
  • 🇮🇳India mitthukumawat

    I think it is good now to have new message. Further we can get feedback and can improve once other related issues get merged with it.

  • 🇩🇪Germany Anybody Porta Westfalica

    @mitthukumawat thanks, I'd be fine with that also.

  • Status changed to Fixed 8 months ago
  • 🇩🇪Germany Grevil

    Alright, great!

    Let's merge this, then! 👍

  • Open on Drupal.org →
    Core: 10.1.4 + Environment: PHP 8.2 & MySQL 8
    last update 8 months ago
    Waiting for branch to pass
  • Open on Drupal.org →
    Core: 10.1.4 + Environment: PHP 8.2 & MySQL 8
    last update 8 months ago
    Waiting for branch to pass
  • Status changed to Needs work 8 months ago
  • Open on Drupal.org →
    Core: 10.1.4 + Environment: PHP 8.2 & MySQL 8
    last update 8 months ago
    Waiting for branch to pass
  • Open on Drupal.org →
    Core: 10.1.4 + Environment: PHP 8.2 & MySQL 8
    last update 8 months ago
    Waiting for branch to pass
  • Assigned to Anybody
  • Status changed to Needs review 8 months ago
  • 🇩🇪Germany Grevil

    Alright, the rebase for this issue took quite a bit of work, but should be correct now! Furthermore, I renamed a config variable so everything is less confusing. Please review once again!

  • Issue was unassigned.
  • 🇩🇪Germany Anybody Porta Westfalica
  • Status changed to Needs work 8 months ago
  • Assigned to Anybody
  • Status changed to Needs review 8 months ago
  • 🇩🇪Germany Grevil

    Alright, everything is finalized now!!

    I tested it throughout and everything works as expected! :)

    Final review pls!

  • Issue was unassigned.
  • Status changed to RTBC 8 months ago
  • 🇩🇪Germany Anybody Porta Westfalica
    • Grevil committed 430514d4 on 2.x
      Issue #3360794: Add option to exclude all non whitelisted file paths (...
  • Status changed to Fixed 8 months ago
  • 🇩🇪Germany Grevil

    Thanks all!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024