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
Comments
Comment #2
tim.plunkettComment #3
tim.plunkettSee also
Comment #4
wim leersSounds great!
Also LOL @ #2.
Comment #5
dawehnerAgreed I think 32 for example should be certainly enough.
Comment #6
wim leersTo reconcile these two requirements:
… I went with -32.
Comment #11
wim leersComment #12
wim leersThere'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/afterdependencies.Comment #13
dawehnerRight, but IMHO there is no reason we could not introduce a before/after system. It would need some BC system anyway.
Comment #14
wim leersYou 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.
Comment #15
catchThe 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.
Comment #16
wim leers:O Really?
Changing priorities would totally break contrib modules.
Comment #17
dawehnerSo let's assume we have this oversimplistic example:
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.
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.
Comment #18
wim leersExactly.
I didn't know about #2352351: Add before/after ordering to events. Let's postpone this on that issue.
Comment #32
smustgrave commentedSeems blocked issue is still opened.