Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Since symfony/http-foundation 5.3: "Symfony\Component\HttpFoundation\RequestStack::getMasterRequest()" is deprecated, use "getMainRequest()" instead.
Steps to reproduce
Update to Symfony 5.3 as in #3161889: [META] Symfony 6 compatibility
Proposed resolution
Extend RequestStack and implement a forward-compatibility shim?
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3209617
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
Comment #2
catchThat sounds good.
Comment #4
longwaveOpened an MR.
I think we also need a followup to rename
StackedRouteMatchInterface::getMasterRouteMatch()
to::getMainRouteMatch()
.Comment #6
catchMarking needs work for re-implementing the deprecation of ::isMasterRequest().
Comment #7
daffie CreditAttribution: daffie commentedI think we can use the solution from #3209618: [Symfony 6] Symfony\Component\HttpKernel\Event\KernelEvent::isMasterRequest() is deprecated, use isMainRequest() instead to fix this issue.
Comment #8
catchI think we could use class_alias() but not sure we need to - if we subclass RequestStack it means we only have to implement the methods we're adding/changing rather than everything on there.
Comment #9
longwaveAdded getMasterRequest() with deprecation message, added SF 5.3 compatibility layer (so we won't trigger deprecations once we are on SF 5.3), fixed tests.
Comment #10
ramankanth CreditAttribution: ramankanth at QED42 for Drupal India Association commentedComment #11
ramankanth CreditAttribution: ramankanth at QED42 for Drupal India Association commentedComment #12
daffie CreditAttribution: daffie commentedThe MR is missing a deprecation message test.
Comment #13
longwaveReworked deprecation to use Drupal style as the Symfony style is confusing when we don't actually require SF 5.3 yet, and added a unit test.
Comment #14
daffie CreditAttribution: daffie commentedThe MR is extending the Symfony request stack and in core.services.yml is the new class replacing the old class.
The old method has been deprecated and there is a deprecation message test.
There is no CR, because it is not a "REAL" Drupal deprecation.
For me it is RTBC.
All Symfony 6 issues are critical.
Comment #15
catch#12 looks great, don't think there's anything left to do here, so +1 to the RTBC.
Comment #17
catchCommitted/pushed to 9.3.x, thanks!
Since this adds a new deprecation and there's no hurry, leaving it out of 9.2
Comment #19
joachim CreditAttribution: joachim at Factorial GmbH commentedDoesn't this need to set a new minimum version of symfony/http-foundation?
`$ composer why -t symfony/http-foundation` says:
which means that my D9.3 site's composer is quite happy with Symfony 4, which obviously then crashes because RequestStack::getMainRequest() doesn't exist.
Comment #20
catchThis caused some contrib breakage #3253542: FacetBlockAjaxController breaks the RequestStack in Drupal 9.3.0. We might want to update the CR to incorporate that. I don't think there's much we could have done to pre-empt it except to have core check method_exists() and fall back to the older method if something is swapping out the service.
Comment #21
catchWe're going to need to keep this shim in Drupal 10, and deprecate it for removal in Drupal 11 - since modules like facets may start using it in the meantime to bridge versions. Have added a change record now.
Comment #22
Daniel KulbeThe typehint in
Drupal::requestStack()
is not correct since this change.