On default local task URLs (i.e. paths that are specifically marked as DEFAULT_LOCAL_TASK and that fall back to their parents), the regular local tasks are duplicated a second time. This effect is for example visible on admin/content/node. The regular path to that page is admin/content, but admin/content/node is supposed to be exactly the same, but it is not.

Comments

aspilicious’s picture

sun’s picture

Jeff Burnz’s picture

Yes it happens with Garland and other themes.

damien tournoud’s picture

Status: Active » Needs review
StatusFileSize
new3.91 KB

The core of the issue is in the "Find all tabs at the same level or above the current one." code:

     // Find all tabs at the same level or above the current one.
-    $parent = $router_item['tab_parent'];
+    $parent = ($router_item['type'] & MENU_LINKS_TO_PARENT ? $router_item['path'] : $router_item['tab_parent']);
     $path = $router_item['path'];
     $current = $router_item;

Also, there is a mess of MENU_DEFAULT_LOCAL_TASK constants used as is when the actually required check is against the MENU_LINKS_TO_PARENT parameter.

sun’s picture

+++ includes/menu.inc
@@ -1733,7 +1733,7 @@ function menu_local_tasks($level = 0) {
     // Find all tabs below the current path.
-    $path = ($router_item['type'] == MENU_DEFAULT_LOCAL_TASK ? $router_item['tab_parent'] : $router_item['path']);
+    $path = ($router_item['type'] & MENU_LINKS_TO_PARENT ? $router_item['tab_parent'] : $router_item['path']);

@@ -1788,8 +1788,9 @@ function menu_local_tasks($level = 0) {
+  ¶
     // Find all tabs at the same level or above the current one.
-    $parent = $router_item['tab_parent'];
+    $parent = ($router_item['type'] & MENU_LINKS_TO_PARENT ? $router_item['path'] : $router_item['tab_parent']);

Hm. The first, I'd agree with :)

The second. Is reversed? (not sure)

Powered by Dreditor.

damien tournoud’s picture

That's by design.

Because in the first case you gone up a tab, in the second case you want no to go up a tab, or you will get a duplicate level in the middle.

Status: Needs review » Needs work

The last submitted patch, 755638-menu-tasks-messed-up.patch, failed testing.

sun’s picture

Status: Needs work » Needs review

#4: 755638-menu-tasks-messed-up.patch queued for re-testing.

damien tournoud’s picture

Status: Needs review » Needs work

What this code seems to do is:

  1. Fetch all the hierarchy of a 'tab root'
  2. Find the tabs below the current tab
  3. Find the tabs above or at the same level of the current tab

I have no idea why (3) is necessary. It seems that my patch above just skipped it.

damien tournoud’s picture

Status: Needs work » Needs review
StatusFileSize
new1.24 KB

This feels closer to the correct patch.

sun’s picture

+++ includes/menu.inc
@@ -1710,6 +1710,11 @@ function menu_local_tasks($level = 0) {
     if (!$router_item || !$router_item['access']) {
       return $empty;
     }
+
+    if ($router_item['type'] & MENU_LINKS_TO_PARENT) {
+      $router_item = menu_get_item($router_item['tab_parent']);
+    }

Edge-case, but possible: Can we move this above the 'access' check?

134 critical left. Go review some!

damien tournoud’s picture

StatusFileSize
new1.56 KB

We have access checks everywhere in that function, so I don't believe it makes a lot of difference. But here is one with the access control on the main router moved below.

aspilicious’s picture

I can tell that the patch "works"...
No more duplication of tabs!

So if you agree about the code we can mark this (almost ciritcal) patch rtbc.

yoroy’s picture

Issue tags: +Usability

I searched before posting for a new issue for a change. subscribe.

aspilicious’s picture

Lets review this fast, as this is a very clear visual problem we are getting a lot of dupplicated issues:

#758884: duplicated tabs on menu_default_local_task page

pasqualle’s picture

subscribe

rickvug’s picture

I believe I was about to post about the same issue as here. The first time I visit the dashboard I don't see the duplicate tabs. After I edit the dashboard the links show up. For what it is worth, here's a 20 second screen cast of the problem: http://youtu.be/fG7YWRg7Ue0.

rickvug’s picture

StatusFileSize
new1.56 KB

I tested the lastest patch in #12 and it fixed the issue. It looks like there is one minute typo in the comments. Here's the change:

"If this router item points to its parent, start from the parents to compute tabs and actions."

Attached is a manually edited patch with documentation change.

aspilicious’s picture

Status: Needs review » Reviewed & tested by the community
sun’s picture

yoroy’s picture

yoroy’s picture

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD. Thanks!

Status: Fixed » Closed (fixed)
Issue tags: -Usability

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