Problem/Motivation

There is a problem with route permissions for node/{node}/children lacking context.

Steps to reproduce

An example is that if you have moderation_sidebar installed you can see the 'Children' tab when on any node page that shows the local tasks, but it's missing from the moderation_sidebar as a secondary task.

In addition, the following should work from any location, but currently doesn't.

$route = Url::fromRoute('entity.node.entity_hierarchy_reorder', [
  'node' => 25503,
]);
$user = User::load(1);

$access = $route->access($user);
echo ($access ? 'TRUE' : 'FALSE');

Proposed resolution

I had a look at how EntityAccessCheck solves the problem, and it passes the route as context to the ->access() function. Initial testing suggests the same can be done here.

Remaining tasks

Run some tests.

Comments

nterbogt created an issue. See original summary.

nterbogt’s picture

An initial implementation based on entity_hierarchy. Tested in context of nodes, but not wider than that. Also tested above pseudo code for route permissions.

nterbogt’s picture

Status: Active » Needs review
larowlan’s picture

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

We should be able to test this with the $url->access code in the issue summary in a kernel test

nterbogt’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new4.66 KB

Unable to test as a Kernel test. Route wasn't registering properly.

A functional test in the meantime.

nterbogt’s picture

Status: Reviewed & tested by the community » Needs work

Just checking the patch again.

nterbogt’s picture

Status: Needs work » Reviewed & tested by the community

It's good. Just rechecked locally.

larowlan’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: -Needs tests
StatusFileSize
new1.29 KB
new4.31 KB

In kernel tests you need to manually rebuild routes

  • larowlan committed aa0e0a12 on 3.x
    Issue #3356967 by nterbogt, larowlan: Route permissions have trouble...
larowlan’s picture

Status: Needs review » Fixed

Will cut a release today

  • larowlan committed aa0e0a12 on 4.x
    Issue #3356967 by nterbogt, larowlan: Route permissions have trouble...

Status: Fixed » Closed (fixed)

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