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.
During fixing the remaining bugs for the conversion of views to use routes it became clear that menu links always returns a FALSE,
if the access is done only via the route and not via access_callback/access_argument.
Comment | File | Size | Author |
---|---|---|---|
#23 | drupal-1938960-23.patch | 9.58 KB | dawehner |
#23 | interdiff.txt | 2.13 KB | dawehner |
#21 | menu_translate-1938960-21-FAIL.patch | 4.42 KB | tim.plunkett |
#21 | menu_translate-1938960-21-PASS.patch | 7.3 KB | tim.plunkett |
#21 | interdiff.txt | 941 bytes | tim.plunkett |
Comments
Comment #1
dawehnerHere is test and a fix.
It's amazing that you can use a Drupal Unit test to test access.
Comment #2
tim.plunkettThis is a huge problem, but great job @dawehner for both finding it and fixing it!
Comment #3
dawehnerOne thing I'm not sure about is that _menu_translate() doesn't care about symfony routers at all, even it's called in a lot of places:
Comment #4
catchCommitted/pushed #1, leaving this open for _menu_translate() inconsistency.
Comment #5
tim.plunkettHere's a patch. Needs a test similar to the one in #1.
Comment #6
Wim LeersIn the case of
admin/structure/views/view/frontpage
(admin/structure/views/view/%
inhook_menu()
,/admin/structure/views/view/{view}/{op}
in the case of the routing system), the patch in #5 fails. Possibly because no route is defined for/admin/structure/views/view/{view}
, i.e. without the/{op}
part?The use case: contextual links (
menu_contextual_links()
) use the above path to see if the user might have access to "operation paths" below that "entity path".Comment #7
dawehnerThere is a route defined for it:
The problem is somehow a bit deeper. The backtrace is something like:
ContextualController.php:44->render()
contextual.module:contextual_pre_render_links()
menu_contextual_links()
menu_get_item()
_menu_translate()
Compared to the menu_link_.... approach here we don't have the route_name stored in {menu_route}
so there is no obvious way in _menu_translate() to get the route name. I guess we should add this key temporary so it's possible to fix it. Does someone has an oppinion?
#914382: Contextual links incompatible with render cache
Comment #8
tim.plunkettI'm pretty sure that _menu_translate() is broken. I had huge problems with it in the field_ui issue.
Comment #9
dawehnerThis should work already, but I got stuck with writing a test for _menu_translate().
Wow this old menu system could have really tried to not do everything in one function.
Comment #11
dawehner#9: drupal-1938960-9.patch queued for re-testing.
Comment #13
tim.plunkettComment #14
tim.plunkett#1982920: Tabs access control is broken (nonexistent?) is likely a duplicate.
Comment #16
tim.plunkettOkay, this works locally, and fixes #1982920: Tabs access control is broken (nonexistent?), so closing that.
Still needs tests.
Comment #18
tim.plunkettBefore:
After:
Comment #19
tim.plunkettHere is a web test. @msonnabaum agrees that _menu_translate() is too messy for a unit test.
Comment #21
tim.plunkettI rolled those wrong. Also, needed a change to TreeAccessTest after all.
Comment #22
dawehnerThat's great!
OOOH This one could certainly get a unit test
Comment #23
dawehnerHere is one.
Comment #24
tim.plunkettGetting in line
Comment #25
dawehnerWe certainly don't need tests anymore.
Comment #26
tim.plunkett.
Comment #27
Crell CreditAttribution: Crell commentedI'm Larry Garfield, and I approve this patch.
Comment #28
webchickGreat, thanks for the fix and the tests! I just added a small @todo on that else branch so we remember to remove it once/if all routes are converted.
Committed and pushed to 8.x. Thanks!