Problem/Motivation

The module currently uses a middleware but it does not perform any action whatsoever with the request, the very first line of the middleware implementation is calling the kernel handle method.

The event I am initially proposing to use is kernel.terminate which is the one the Automated Cron module uses.

I am raising this first to discuss what is the best approach, once that is agreed we can work on changing the code (which should not be a huge change).

Steps to reproduce

NA

Proposed resolution

Use an EventSubscriber on the Response instead, this way we have access to both the Request and Response objects and can act base on that data.

Remaining tasks

Make the UrlRegistrar an EventSubscriber instead.

User interface changes

None

API changes

None (IMO this is not considered an API change since users are not supposed to be using this middleware in any way)

Data model changes

None

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dungahk created an issue.

vivek panicker’s picture

I think this is a very valid suggestion and would not interfere with the Drupal Core routing system also.
We should go ahead with this.
Kernel.terminate would be a good time to do it since by that time the response would already have been sent, so there wouldn't be any extra processing happening during the request.

ericgsmith’s picture

We have to make a BC break anyway to support Drupal 11 - so if anybody wants to action this idea I'm not opposed to it. I will need to create a 2.x branch for it.

ericgsmith’s picture

If we use kernel.terminate then the code will not run if page cache is handling the response - in the current state this is good as the module tries to skip this scenario anyway, but this has a potential side effect if https://www.drupal.org/project/purge_queuer_url/issues/3045503#comment-1... means we need to be able to know when the page is served by page cache.