Problem/Motivation

DynamicPageCacheSubscriber::onResponse() has a priority of 100.
It is documented as needing to run before HtmlResponseSubscriber::onRespond(), which has a priority of 0.

When trying to implement a response subscriber to add cache tags, it needed to be set to 101 to function.

Proposed resolution

Allow vanilla response subscribers to have a 0 priority by making DynamicPageCacheSubscriber and HtmlResponseSubscriber negative.

Remaining tasks

Pick a negative priority for each that works.

User interface changes

N/A

API changes

Not really, right?

Data model changes

N/A

CommentFileSizeAuthor
#6 2566019-6.patch1.65 KBwim leers
#2 qth3x.jpg33.24 KBtim.plunkett

Comments

tim.plunkett created an issue. See original summary.

tim.plunkett’s picture

Issue summary: View changes
StatusFileSize
new33.24 KB

tim.plunkett’s picture

wim leers’s picture

Sounds great!

Also LOL @ #2.

dawehner’s picture

Agreed I think 32 for example should be certainly enough.

wim leers’s picture

Status: Active » Needs review
StatusFileSize
new1.65 KB

To reconcile these two requirements:

Pick a negative priority for each that works.

Agreed I think 32 for example should be certainly enough.

… I went with -32.

Status: Needs review » Needs work

The last submitted patch, 6: 2566019-6.patch, failed testing.

The last submitted patch, 6: 2566019-6.patch, failed testing.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

wim leers’s picture

Component: request processing system » dynamic_page_cache.module
wim leers’s picture

Title: DynamicPageCacheSubscriber::onResponse()'s priority is unreasonably high. » HtmlResponseSubscriber and DynamicPageCacheSubscriber should have negative priorities so that vanilla response subscribers can have priority zero
Version: 8.2.x-dev » 9.x-dev
Component: dynamic_page_cache.module » request processing system
Category: Bug report » Task
Priority: Normal » Major
Issue tags: +DX (Developer Experience), +DrupalWTF

There's no hope of changing this in 8.x, because it'd be an API break. :(

This is why Symfony's priority-based system and Drupal's weight-based system sucks: it requires manual management/tweaking by developers. What we need, is explicit before/after dependencies.

dawehner’s picture

Right, but IMHO there is no reason we could not introduce a before/after system. It would need some BC system anyway.

wim leers’s picture

You cannot introduce a before/after system without breaking BC. You can't have both priority+before/after, nor can you generate before/after declarations based on priorities.

catch’s picture

Version: 9.x-dev » 8.3.x-dev
Priority: Major » Normal

The specific priorities of event subscribers aren't a public API, so this could be done in a minor theoretically. We might decide not to do it, but that's not the same as not being able to.

Also we could add before/after and deprecate priorities in a minor I think - first apply priorities, then apply before/after - the newest API wins. Sometimes you might lose out with a priority, but that will also happens if someone gazumps your weight/priority with the existing system.

wim leers’s picture

The specific priorities of event subscribers aren’t a public API

:O Really?

Changing priorities would totally break contrib modules.

dawehner’s picture

You cannot introduce a before/after system without breaking BC. You can't have both priority+before/after, nor can you generate before/after declarations based on priorities.

So let's assume we have this oversimplistic example:

  • A subscriber with prio 32
  • A subscriber with prio 16
  • A couple of normal subscribers with prio 0

Let's say we would say that the second one should be after the first one, but that's it, it would potentially run even after the normal subscribers. This is IMHO though not a problem because a) those subscribers would explicitly opt into this behaviour, so if they know they also need to run before another subscriber, they'd specify that as well.

Changing priorities would totally break contrib modules.

So we couldn't change priorities of subscribers contrib modules might rely on. To be honest, though I still think #2352351: Add before/after ordering to events would be a good idea to explore. Maybe we'll expand the list of events, so in case we do, we could leverage this before/after system at least for new subscribers.

wim leers’s picture

Title: HtmlResponseSubscriber and DynamicPageCacheSubscriber should have negative priorities so that vanilla response subscribers can have priority zero » [PP-1] HtmlResponseSubscriber and DynamicPageCacheSubscriber should have negative priorities so that vanilla response subscribers can have priority zero
Status: Needs work » Postponed

So we couldn’t change priorities of subscribers contrib modules might rely on.

Exactly.

I didn't know about #2352351: Add before/after ordering to events. Let's postpone this on that issue.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Seems blocked issue is still opened.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.