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.

Comments

catch created an issue. See original summary.

catch’s picture

Title: Update stackphp/builder for Symfony 6 support » Update stackphp/builder for Symfony 6 support or remove it as a dependency

@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.

catch’s picture

@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

longwave’s picture

Yeah, 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.

longwave’s picture

I'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:

Using configuration, we could also imagine new tags. E.g. one to allow filtering a frame while embedding a stack, another to allow replacing a frame by a new one, another for inserting a frame before/after another one - doing so either while embedding and/or by altering an existing stack definition. I didn't mention it, but frames can be named, this could help.

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 responder property, 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.

longwave’s picture

Status: Active » Needs review
StatusFileSize
new9.51 KB

This patch copies Stack\StackedHttpKernel to Drupal\Core\StackMiddleware\StackedHttpKernel, updates all references and tests, and removes stack/builder as a dependency.

longwave’s picture

StatusFileSize
new9.51 KB
new854 bytes

Fix coding standards.

Status: Needs review » Needs work

The last submitted patch, 7: 3258902-7.patch, failed testing. View results

spokje’s picture

Status: Needs work » Needs review
StatusFileSize
new890 bytes
new10.59 KB

Fixing failing tests

daffie’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs release manager review

All 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.

daffie’s picture

Title: Update stackphp/builder for Symfony 6 support or remove it as a dependency » [Symfony 6] Update stackphp/builder for Symfony 6 support or remove it as a dependency
Issue tags: +Symfony 6, +Drupal 10
longwave’s picture

Title: [Symfony 6] Update stackphp/builder for Symfony 6 support or remove it as a dependency » [Symfony 6] Bring stackphp/builder into core for Symfony 6 compatibility and remove it as a dependency
Issue tags: +Needs issue summary update

Updated 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.

catch’s picture

Removing 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.

daffie’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update

Update the IS.

alexpott’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Fixed

Committed c97b854 and pushed to 10.0.x. Thanks!

I re-did the composer.lock to resolve conflicts.

  • alexpott committed c97b854 on 10.0.x
    Issue #3258902 by longwave, Spokje, catch, daffie: [Symfony 6] Bring...

Status: Fixed » Closed (fixed)

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

xjm’s picture

Status: Closed (fixed) » Needs review
Issue tags: +10.0.0 release notes, +Needs change record

Tagging for release notes mention.

The release note here says that there is no functional change, but presumably at least use statements need to be updated to load the thing from the core namespace instead? Should it have a small change record for that?

catch’s picture

@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.

xjm’s picture

Issue summary: View changes
Issue tags: -Needs change record

Confirmed that there are no contrib usages, thanks. Updating the release note to clarify that the service is unchanged.

xjm’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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