Problem/Motivation
Over at #2429617-303: Make D8 2x as fast: Dynamic Page Cache: context-dependent page caching (for *all* users!), failures in CommentNonNodeTest
were discovered.
(The SmartCache patch caches all pages, with some exceptions. One of those exceptions: any admin route will not be cached.)
They happened were because entity_test/structure
is actually an admin route, but wasn't marked as such because it doesn't have the admin/
prefix. So, changing the system path for that route to have that prefix fixes the problems, because those routes are then correctly marked as admin routes.
This was introduced several years ago, in "the early new routing system days". I checked with Berdir, and he confirms/thinks that was simply an oversight.
Proposed resolution
Fix that oversight: make that route have the admin/
prefix in its system path.
Remaining tasks
Review.
User interface changes
None.
API changes
None.
Data model changes
None.
Beta phase evaluation
Unfrozen changes | Unfrozen because it only changes tests. |
---|---|
Disruption | Contrib modules that use this same route in tests will need to be updated, but only if they weren't using the route name already. |
Comment | File | Size | Author |
---|---|---|---|
#18 | 2551429-18.patch | 2.53 KB | Wim Leers |
Comments
Comment #2
Wim LeersFurther indication this was definitely intended to be an admin route:
Note the name of the controller.
Comment #3
jibranThis will break a lot of tests for me in contrib. Anyways good to have this sanity.
Beta Eval test only change.
Comment #4
Wim LeersThanks, created an actual beta evaluation.
Also: to avoid your tests from breaking for this, don't use
$this->drupalGet('some/path')
but$this->drupalGet(Url::fromRoute('some_route')
.Comment #6
Wim LeersWoops, that included a small unintended hunk.
Comment #7
larowlanCan't you just flag the route as admin in the yml and leave the paths as is?
Comment #8
larowlanEg block/add
Comment #9
alexpottLet's do less breaking and do what @larowlan suggests
Comment #10
Wim LeersComment #11
Wim LeersActually, #10 does NOT work.
Because
\Drupal\system\EventSubscriber\AdminRouteSubscriber::alterRoutes()
:So this only sets the admin route option for any specific route that has the
/admin
prefix.But… we want routes that use the route modified in #10 as a base route, to also be admin routes. Otherwise, we're still not fixing the problem #2429617: Make D8 2x as fast: Dynamic Page Cache: context-dependent page caching (for *all* users!) uncovered.
Which means we'd have to modify
\Drupal\field_ui\Routing\RouteSubscriber::alterRoutes()
to also inherit the options of the base route.Conclusion
We have two options:
_admin_route
option, and make Field UI's logic that generates field UI routes inherit the options from the base route it is given. That's what this patch does.Comment #12
jibranI think if we are not doing this already then this is a bug.
Let's add tests for this.
Comment #13
stefan.r CreditAttribution: stefan.r commentedComment #14
jibranThanks @stefan.r. This seems ready just needs a test only patch and interdiff :D
You can create test only patch by reverting this hunk.
Comment #15
dawehnerShould we not simplify this code a bit and just load the route object itself from the router.route_provider service by its name? Afaik its enough test coverage if you do it like that
Comment #16
Wim LeersComment #17
stefan.r CreditAttribution: stefan.r commentedI probably won't be able to today, can one of you?
Comment #18
Wim LeersDone.
Also:
s/assert/test/, otherwise it won't run as a test :)
Comment #19
dawehnerHa, this is why jibran asked for a test only patch :)
Comment #20
alexpottThis issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed 13e93a9 and pushed to 8.0.x. Thanks!