Problem/Motivation
Postponed on having a release to update to https://github.com/stackphp/builder/pull/30
Proposed resolution
Copy the class Stack\StackedHttpKernel to Drupal\Core\DependencyInjection\Compiler\StackedKernelPass and use the copied class instead of the one from the dependency: stack/builder.
Remaining tasks
TBD
User interface changes
None
API changes
Added the copied class Drupal\Core\DependencyInjection\Compiler\StackedKernelPass.
Data model changes
None
Release notes snippet
stack/builder has been removed as a dependency and its functionality is now provided by a core API. The http_kernel service is unchanged.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 3258902-9.patch | 10.59 KB | spokje |
| #9 | interdiff_7-9.txt | 890 bytes | spokje |
Comments
Comment #2
catch@fabpot recommends not using this per the github PR.
#2343677: Stack middleware suffers from incomplete service construction discussed removing it in 2014 although doubt much is relevant now.
Comment #3
catch@fabpot might mean using stack decoration support from the container itself. Question then is whether our own container supports this.
https://symfony.com/blog/new-in-symfony-5-1-stack-decorators
Comment #4
longwaveYeah, looks like Symfony's approach is just to declare all this at service configuration time. The PR that added this feature has more examples: https://github.com/symfony/symfony/pull/36373
If we don't want to do this just yet we could copy StackedHttpKernel into core and update it for Symfony 6, it's only one class.
Comment #5
longwaveI've read the PR in detail and I think it is missing some parts for us to be able to use it.
We order services by priority and modules can decide to insert services at any level into the middleware stack, e.g. the page_cache middleware inserts itself into the middle of the chain. As far as I can see Symfony hasn't yet implemented this, as per the PR:
While these are suggested as future features in the PR, there have been no relevant changes to the compiler pass to implement this: https://github.com/symfony/dependency-injection/commits/6.1/Compiler/Res...
The page cache middleware also has a Drupalism in the
responderproperty, which makes all subsequent services lazy, in the assumption that the responder will not usually be calling further down the stack. This isn't implemented in the Symfony stack syntax, although we could probably do it as a subsequent compiler pass.However, as far as I can see we need the ability to modify existing stacks and Symfony not providing that yet is a deal breaker for us. Therefore I suggest we copy StackedHttpKernel into core and continue to use it as a middleware provider as the easiest route forward.
Comment #6
longwaveThis patch copies
Stack\StackedHttpKerneltoDrupal\Core\StackMiddleware\StackedHttpKernel, updates all references and tests, and removesstack/builderas a dependency.Comment #7
longwaveFix coding standards.
Comment #9
spokjeFixing failing tests
Comment #10
daffie commentedAll the code changes look good to me.
The class from the dependency that we use is copied to Drupal. Therefor we do not need the package anymore.
Adding the tag for a release manager review as we are removing a dependency.
For me it is RTBC.
Comment #11
daffie commentedComment #12
longwaveUpdated issue title to match the chosen approach. Issue summary needs updating to match, will try to get to it tomorrow if nobody else gets there first.
Comment #13
catchRemoving the dependency to support < 100 lines of code is great. We can always to to factor those away later, but sounds like it'd be more in compiler passes let alone the missing features at the moment. Untagging for release manager review.
Comment #14
daffie commentedUpdate the IS.
Comment #15
alexpottCommitted c97b854 and pushed to 10.0.x. Thanks!
I re-did the composer.lock to resolve conflicts.
Comment #18
xjmTagging for release notes mention.
The release note here says that there is no functional change, but presumably at least
usestatements need to be updated to load the thing from the core namespace instead? Should it have a small change record for that?Comment #19
catch@xjm the class itself is only used internally - the middlewares don't interact with it and nor does anything else except the kernel itself and compiler pass that use it, so I don't think a CR would be useful for anyone.
Comment #20
xjmConfirmed that there are no contrib usages, thanks. Updating the release note to clarify that the service is unchanged.
Comment #21
xjm