Example use case (from #1115998: Revamp core and UI permissions):

I have a local task 'user/%user/relationships' and a number of local tasks below that like 'user/%user/relationships/an_id'. For those with an_id, I have a custom access callback and "'access arguments' => array('view', 1, 3),". so it should pass an_id as third argument to my access callback.

However, it doesn't do that, because it only knows about the path elements/map elements of the router item. This is because menu_get_local_tasks() passes the unchanged $map information of the parent router_item to any local tasks.

I have fixed it by appending all addditional path elements for each local tasks, patch coming up in a second.

Comments

berdir’s picture

Status: Active » Needs review
StatusFileSize
new1.21 KB

And here is the patch.

berdir’s picture

Tagging with backport tags. The code in 6.x is slightly different but the same bug exists too there.

BenK’s picture

Subscribing since I'm working on the corresponding issue on the User Relationships module.

chx’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests
berdir’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new3.27 KB
new5.08 KB

Ha, the new tests actually showed that my patch didn't fully solve the issue yet.

The tests add 4 menu items now. The normal menu item menu-test/local-tasks and the three following local tasks:

menu-test/local-tasks/1
menu-test/local-tasks/2
menu-test/local-tasks/3

There is an access callback function that disallows access to the second item.

It already worked when you accessed menu-test/local-tasks. But when you access menu-test/local-tasks/3 for example, we need to use slice away the third part of the url.

The new patch is now doing that based on the given tab_parent.

Two patches, the second only contains the tests to prove that they're working.

berdir’s picture

Note that the current approach will not work when you have multiple levels of local tasks, I'm not sure how to solve that at this point. Suggestions?

Status: Needs review » Needs work

The last submitted patch, fix_map_handling_for_local_tasks_tests_only.patch, failed testing.

cpliakas’s picture

This is a nasty little issue. Just ran into it at http://drupal.org/node/1404590#comment-5478056. Unfortunately I don't have any suggestions at this time on how to fix the core issue, but I might try to help if time permits.

berdir’s picture

Status: Needs work » Needs review
Issue tags: -Needs backport to D6, -Needs backport to D7
kscheirer’s picture

jhedstrom’s picture

Wow, this took quite a bit of digging to find. Currently testing the patchin #5 out on a D7 site, seems to work as advertised. Will dig into why tests are failing in 8.

jhedstrom’s picture

Here is #5 re-rolled against current 8.x. Again, the tests are included as a separate patch in order to demonstrate the failure.

The last submitted patch, drupal-menu-local-tasks-1137052-12.patch, failed testing.

jhedstrom’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 12: drupal-menu-local-tasks-1137052-12.patch, failed testing.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

catch’s picture

Version: 8.9.x-dev » 7.x-dev
Issue summary: View changes
Issue tags: +Bug Smash Initiative

Local tasks in Drupal 7 are no longer part of the routing system. Moving this back to 7.x

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.