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-kernel 5.3: "Symfony\Component\HttpKernel\Event\KernelEvent::isMasterRequest()" is deprecated, use "isMainRequest()" instead.
Steps to reproduce
Update to Symfony 5.3 as in #3161889: [META] Symfony 6 compatibility
Proposed resolution
Replace the deprecated method with the replacement method.
Remaining tasks
None
User interface changes
None
API changes
The method Symfony\Component\HttpKernel\Event\KernelEvent::isMasterRequest() is deprecated in Symfony 5.3. The method has been replaced by Symfony\Component\HttpKernel\Event\KernelEvent::isMainRequest().
Data model changes
None
Release notes snippet
TBD
Comment | File | Size | Author |
---|---|---|---|
#27 | interdiff_23-27.txt | 1.06 KB | Neslee Canil Pinto |
#27 | 3209618-27.patch | 14.6 KB | Neslee Canil Pinto |
Comments
Comment #2
longwaveComment #3
catchShould we combine this with #3209617: [Symfony 6] Symfony\Component\HttpFoundation\RequestStack::getMasterRequest() is deprecated, use getMainRequest() instead? Seems like it'll depend on the subclass used in the other issue.
Comment #4
longwave@catch I thought about that but I think the two classes are fundamentally different, we can do the changes independently, and I can see how to make an FC shim for RequestStack but this one looks far more difficult:
As an example:
We might have to override all the places the event classes are instantiated? But because the classes are final, we can't extend them and if we just replace them then existing type checks won't work:
So this one looks somewhat tricky.
Comment #5
catchI can hear class_alias() calling from across the hills. It means we'll have to copy
HttpKernel
to our own version, but it should handle the replacement angle.Comment #6
catchThis sort of thing, completely untested patch.
Comment #7
andypostComment #8
catchComment #9
catchNow with some basic test coverage for the forward compatibility layer.
Comment #11
catchTest failures are the new deprecation kicking in, this ought to fix hopefully.
Comment #12
longwaveNice work!
Let's add an @todo to remove this when we use Symfony 6.
I think this should be merged into the following docblock and say we copy the code directly from Symfony, again with the @todo to remove.
Do we need a deprecation test for this?
And finally let's add the same @todo here.
Comment #13
catch1. Made this 5.3 since the new method will be available then.
2. Yep. Tried to tidy this up a bit.
3. Yes probably although I'm failing to to get the test to pass locally, trying a 'hit and hope' with DrupalCI.
4. As with #2.
Comment #14
catchFixing the cs issues.
Comment #16
andypostIs the
MASTER_REQUEST
const still not deprecated?Comment #17
longwave@andypost see #3209723: [Symfony 6] Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST is deprecated, use ::MAIN_REQUEST instead
Comment #18
catchFeel like I've seen the deprecation testing blow up like this before, but not seeing what the problem is with the test.
Comment #19
longwaveI can reproduce locally but also not sure why the deprecation isn't firing.
However we can convert the kernel test to a unit test, which seems to work.
Comment #20
catchI double checked that that class_alias was working in the legacy test (just in case we were somehow loading Symfony's KernelEvent), but it wasn't that, so something to do with the deprecation listener itself I think - but didn't get far enough. Unit test is better anyway though and seems happy.
Comment #22
daffie CreditAttribution: daffie commentedThe patch looks good. Just 2 nitpicks.
Nitpick: A single empty line is enough.
Nitpick: The slash is not needed here.
Comment #23
catchAddressing #22.
Comment #24
daffie CreditAttribution: daffie commentedThe added class is extending the Symfony class that in version 5.3 will throw a deprecation message.
The added class is being added by a class_alias call in the class DrupalKernel.
There is testing for class_alias call and the deprecation message.
All calls to the deprecated method have been replaced.
Added a CR and updated the IS.
For me it is RTBC.
Comment #25
daffie CreditAttribution: daffie commentedAll Symfony 6 related issues are critical.
Comment #26
Gábor HojtsyAs per https://www.drupal.org/docs/develop/standards/api-documentation-and-comm...
These should IMHO point to #3197482: Update Drupal 10 to depend on Symfony 5.4 (as a stepping stone to Symfony 6, for deprecation checking support). That would make it easier to find the corresponding issue and to find the todos referencing it as well.
Comment #27
Neslee Canil PintoAdded @todo reference issue link
Comment #28
daffie CreditAttribution: daffie commentedThe point of @gabor has been addressed.
Back to RTBC.
Comment #29
alexpottI've felt for a while we should have a core/class_aliases.php which should be included by composer as this would mean that our aliases are decoupled from including this class. This has a big benefit of meaning that in unit tests we'll use our class even when DrupalKernel has not be included. I think we should open a follow-up to move this to such a file.
Committed and pushed 85ee5e164b to 9.3.x and b1fd5e7cc9 to 9.2.x. Thanks!
removed the @see's on commit - the link can go in the @todo just fine.
Comment #32
alexpottCreated the follow-up #3214234: Add core/class_aliases.php