Needs work
Project:
Drupal core
Version:
main
Component:
routing system
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
3 Feb 2017 at 19:33 UTC
Updated:
13 Mar 2023 at 20:17 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
dawehnerWe added __call simply to fetch potential calls we haven't thought about. I think we should totally add function if we forgot about any of them.
That's something which is its own issue totally, IMHO :)
Comment #3
pwolanin commented@dawehner - well the other class only has a single method, so I think this issue is about better DX by removing extra layers of indirection
Comment #4
dawehnerIt fullfills me with joy to do that
Comment #5
dawehnerI guess this step is enough for now. To be honest I would love to tag the router class as internal. It is not in anyone's business really to manipulate the router. There are too many implicit assumptions made all over the place.
Comment #6
pwolanin commented@dawehner did you forget the patch?
Comment #7
dawehneryes
Comment #9
dawehnerIs there really that much value in this unit test?
Comment #10
pwolanin commentedDo we know that the route attributes start out empty?
Seems like it's possible the return value is not the same as it used to be when not checking access?
Comment #11
cilefen commentedComment #12
dawehnerDo we care if they are not empty in the beginning?
Comment #13
pwolanin commented@dawhener - if they don't start out empty, the return value of the non-access-aware router is different before an after the patch (and the 2 routers in general return different results).
So - this might also be a bug fix to make those consistent, I just want to be sure it's intended
Comment #14
dawehnerIsn't still the same code running at the end?
Comment #15
pwolanin commented@dawhner - for the access aware one yes
for the non-access-aware one, it was returning the parameters directly without merging them with the request attributes.
Comment #16
dawehnerOh I see, mhh, do you think we should return all attributes?
Comment #17
klausiCool, I like this issue :)
The new methods on the Router class should have unit tests. We should port over that from the removed AccessAwareRouterTest.
Comment #18
pwolanin commentedI think this patch is probably fine since it's now consistent. Should probably verify that with test coverage.
Comment #20
dawehnerHere are the previous unit tests converted over ...
Comment #21
dawehnerOh I also kept a BC layer around for AccessRouter, you never know ...
Comment #23
dawehnerI forgot to remove the AccessAwareRouterTest ...
Comment #24
wim leersCan't we simplify this even further, to inherit as much as possible from
router? That'd make the relation clearer.8.5.x by now.
Stupid whitespace nit here.
Addressed all my feedback. Thoughts?
Comment #25
dawehnerOh wow, I did not knew this is actually possible.
I think this should be major given what #2883680-69: Force all route filters and route enhancers to be non-lazy argued abotu.
Comment #26
wim leersSo you liked #24.1? If so, I'd be happy to RTBC. Or perhaps we need @tim.plunkett to RTBC?
Comment #27
dawehnerI guess its another case where we need a subsystem maintainer review?
Comment #28
wim leersYep, I think so!
Comment #29
tim.plunkettThis patch looks great, and is a nice cleanup.
Wow, that is interesting. The brittleness of
index_5is worrisome, I hope we don't regret this later.Can we keep this comment? It is odd that we don't return $parameters, so we should document why we alter the request at all.
In theory we should put all of this within the if(), and return $parameters when $this->checkAccess is false.
Though WTF I'd really like to see access checks stop expecting that they can manipulate the request directly...
nit: s/Apply/Applies
Very close to RTBC!
Comment #30
dawehnerThank you tim!
I hope we never swap the order of parameters ... given that this would fuck up other routers, of there are probably zero.
Nice observation
If things aren't changed it doesn't make a difference anyway, right?
Comment #31
tim.plunkettSurely no one would ever change the arguments to the router... #2883680: Force all route filters and route enhancers to be non-lazy
😆
You are right, it doesn't matter, since the calling code (\Symfony\Component\HttpKernel\EventListener\RouterListener) immediately calls
on this return value.
Comment #32
dawehner👏
Comment #33
wim leers🎉
Comment #34
alexpottThis should be linked to the CR no? Which I think we need.
Trigger a deprecation notice in the constructor?
Comment #35
dawehnerSure, let's do that.
Comment #36
borisson_#35 correctly fixes the remarks in #34, back to RTBC.
Comment #37
dawehnerComment #38
alexpottUpdating the issue summary to reflect the final patch.
Comment #39
alexpottI wonder what we should be doing with
\Drupal\Core\Routing\AccessAwareRouterInterface? Should that be deprecated too?Also do we have a hard API break if the router service no longer implements
\Drupal\Core\Routing\AccessAwareRouterInterface?Comment #40
alexpottSo part of #39 is incorrect. The patch changes
\Drupal\Core\Routing\Routerto implementAccessAwareRouterInterface. But this brings another question - what does it mean that a router can have theAccessAwareRouterInterfacebut not check access?Comment #41
dawehnerMhh, this is an interesting question.
We could keep the interface around as some form of documentation.
Instead of the making it possible to enable the access checking via constructor argument, we could continue having the
AccessAwareRouteraround, but now it extends the base router and sets the property on the object to be TRUE by default.This way we just change the internal details of the code, but don't touch anything visible from the outside.
What do people think about this approach?
Comment #42
dawehnerHere is the implementation of #41
Comment #44
tim.plunkettIf we go down this path, we should follow it to the logical conclusion: move all thought of access from Router back to AccessAwareRouter.
This undoes some of the original patch, but retains the key change to AccessAwareRouter: subclass over decorator.
Comment #45
tim.plunkettThen this really boils down to "Drupal loves inheritance, or, decorators in PHP are not ideal".
And to be honest, none of this yet addresses the first line of the IS, about UrlMatcher::finalMatch no longer being called.
To actually accomplish that, we'd need this change too
which starts to overlap with #2917331: Decouple from Symfony CMF
Comment #46
dawehnerMhh, yeah its a good question whether this makes things still easier to understand or whether its basically refactoring on the spot.
Comment #47
dawehnerSo how should we proceed here?
Comment #51
jibranComment #52
yogeshmpawarComment #53
yogeshmpawarRerolled the patch #44
Comment #58
andypostComment #59
suresh prabhu parkala commentedRe-roll against the latest 9.2.x.
Comment #60
andypostNW for failed pre checks
Comment #61
ayushmishra206 commentedComment #62
ayushmishra206 commentedFixed the error in #59. please review.
Comment #63
andypostNow something is wrong again
Comment #68
andypostre-roll for 10.1 and fix tests with
$this->route->setOption('compiler_class', RouteCompiler::class);Comment #69
andypostAdditionally to #45 there's issue #3238199: \Drupal\Core\Routing\UrlMatcher is dead code
Comment #70
andypostComment #71
smustgrave commentedThe issue summary talks about deprecating AccessAwareRouter but I don't see a deprecated call?
Comment #72
andypostHere's reverted removal with deprecation, could use test but methods now should be defined
Maybe it should be no-op instead of attempt to call missing method?
Comment #73
andypostIt needs work for constructor changes (BC) and not sure we need to keep
_call()patch replaced as deprecated https://www.drupal.org/node/2894934