Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Status: Active » Needs review
FileSize
4.02 KB
3.44 KB

Here is test and a fix.

It's amazing that you can use a Drupal Unit test to test access.

tim.plunkett’s picture

Priority: Normal » Critical
Status: Needs review » Reviewed & tested by the community

This is a huge problem, but great job @dawehner for both finding it and fixing it!

dawehner’s picture

One 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:

  • contextual links
  • local tasks
  • menu_get_item (that's probably not something which will exists in the future)
catch’s picture

Title: Menu access returns FALSE for links with a route item » _menu_translate() doesn't care about new routes
Status: Reviewed & tested by the community » Active

Committed/pushed #1, leaving this open for _menu_translate() inconsistency.

tim.plunkett’s picture

Status: Active » Needs review
Issue tags: +Needs tests
FileSize
848 bytes

Here's a patch. Needs a test similar to the one in #1.

Wim Leers’s picture

Status: Needs review » Needs work

In the case of admin/structure/views/view/frontpage (admin/structure/views/view/% in hook_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".

dawehner’s picture

There is a route defined for it:


views_ui.edit:
  pattern: '/admin/structure/views/view/{view}'
  options:
    tempstore:
      view: 'views'
  defaults:
    _controller: '\Drupal\views_ui\Routing\ViewsUIController::edit'
  requirements:
    _permission: 'administer views'

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

tim.plunkett’s picture

I'm pretty sure that _menu_translate() is broken. I had huge problems with it in the field_ui issue.

dawehner’s picture

Status: Needs work » Needs review
FileSize
7.92 KB

This 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.

Status: Needs review » Needs work
Issue tags: -Needs tests, -VDC

The last submitted patch, drupal-1938960-9.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review

#9: drupal-1938960-9.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +Needs tests, +VDC

The last submitted patch, drupal-1938960-9.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
621 bytes
7.92 KB
tim.plunkett’s picture

Status: Needs review » Needs work

The last submitted patch, menu-translate-1938960-13.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
810 bytes
8.07 KB

Okay, this works locally, and fixes #1982920: Tabs access control is broken (nonexistent?), so closing that.
Still needs tests.

Status: Needs review » Needs work

The last submitted patch, menu-translate-1938960-16.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
22.92 KB
26.63 KB

Before:
before.png

After:
after.png

tim.plunkett’s picture

Here is a web test. @msonnabaum agrees that _menu_translate() is too messy for a unit test.

Status: Needs review » Needs work

The last submitted patch, menu_translate-1938960-19-PASS.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
941 bytes
7.3 KB
4.42 KB

I rolled those wrong. Also, needed a change to TreeAccessTest after all.

dawehner’s picture

That's great!

+++ b/core/lib/Drupal/Core/Access/DefaultAccessCheck.phpundefined
@@ -26,6 +26,6 @@ public function applies(Route $route) {
   public function access(Route $route, Request $request) {
-    return (bool) $route->getRequirement('_access');
+    return $route->getRequirement('_access') === 'TRUE';
   }

OOOH This one could certainly get a unit test

dawehner’s picture

FileSize
2.13 KB
9.58 KB

Here is one.

tim.plunkett’s picture

Issue tags: +Stalking Crell

Getting in line

dawehner’s picture

Issue tags: -Needs tests, -Stalking Crell

We certainly don't need tests anymore.

tim.plunkett’s picture

Issue tags: +Stalking Crell

.

Crell’s picture

Status: Needs review » Reviewed & tested by the community

I'm Larry Garfield, and I approve this patch.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Great, 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!

Automatically closed -- issue fixed for 2 weeks with no activity.