Closed (fixed)
Project:
Drupal core
Version:
10.0.x-dev
Component:
base system
Priority:
Critical
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
15 Sep 2021 at 09:34 UTC
Updated:
5 Jan 2022 at 11:19 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
daffie commentedI am not sure that the fix will work. In all 3 classes we are already have the use-statement:
use Symfony\Component\Routing\RequestContext as SymfonyRequestContext;. My question will the Symfony deprecation code accept "SymfonyRequestContext" instead of the expected "RequestContext".Comment #3
daffie commentedI do not think we can do this in a 9.x branch as there over 170 time the method with the name "getContext()" is overridden in contrib. I do not know how many of those are overriding the method
Symfony\Component\Routing\RequestContextAwareInterface::getContext(). Maybe be careful and commit this in D10.0. See: http://grep.xnddx.ru/search?text=public%20function%20getContext%28&filen....Comment #4
daffie commentedAdding the return type hint to
Drupal/Core/Routing/NullGenerator::getContext().Comment #5
daffie commentedMoving this to the 10.0 branch.
Comment #6
longwaveThis is breaking the contract and returning void if the instanceof check does not pass.
This is breaking the contract because it always returns void.
Comment #7
longwaveComment #8
longwaveUpstream seems to deal with this by keeping a copy of the context inside the object so it can return it if it's not available from elsewhere.
Comment #9
longwaveThis is similar to #3248859: AccessAwareRouter fails PHPStan-0, the instanceof checks here are wrong I think - AccessAwareRouter should receive an instance of RouterInterface and then it never has to worry about whether the router implements interfaces or not, they are all combined into RouterInterface.
Comment #10
murilohp commentedHey @longwave I'm uploading a new patch removing the use statement that is not required anymore, I hope this time the build doesn't fail.
Thanks!
Comment #11
longwaveThank you!
Comment #12
mondrakeComment #13
daffie commentedCan we change this line to:
public function getContext(): SymfonyRequestContext {. To fix the problem as stated in the IS.Comment #14
longwaveAddressed #13 and found another case where we need to add the return type in a test.
Comment #15
daffie commentedThe change to requiring the Symfony\Component\Routing\RouterInterface in the Drupal\Core\Routing\AccessAwareRouter makes that all previous optional calls are now no longer optional. The router object is now allways of the type RequestContextAwareInterface, RouterInterface and UrlGeneratorInterface.
All the code changes look good to me.
For me it is RTBC.
Comment #17
catchDebated whether we need a change record, but given this is a constructor change, it's 10.0.x only, and the likelihood of a router not implementing RouterInterface is extremely low, I think it'd be noise rather than useful.
Committed 3eb8a34 and pushed to 10.0.x. Thanks!