Menu links never actually link to the full path of a MENU_DEFAULT_LOCAL_TASK, only its parent.

/admin/structure/views           <-- Parent
/admin/structure/views/basic     <-- Default local task
/admin/structure/views/advanced  <-- Local task

As a part of #1995620: [policy, no patch] Document how to handle routes for MENU_DEFAULT_LOCAL_TASK, we're considering making the actual default local task path 404.

I'm not 100% sure if #914382: Contextual links incompatible with render cache changed this, but it certainly makes it harder to track down.
I believe that the db_select() in menu_contextual_links() is actually the issue.

Files: 
CommentFileSizeAuthor
#5 menu-contextual-2006636-5.patch3.71 KBtim.plunkett
PASSED: [[SimpleTest]]: [MySQL] 55,838 pass(es).
[ View ]
#4 menu-2006636-4.patch677 bytestim.plunkett
FAILED: [[SimpleTest]]: [MySQL] Setup environment: Test cancelled by admin prior to completion.
[ View ]

Comments

The query in question is this:

db_select('menu_router', 'm')
  ->fields('m')
  ->condition('tab_parent', $router_item['tab_root'])
  ->condition('context', MENU_CONTEXT_NONE, '<>')
  ->condition('context', MENU_CONTEXT_PAGE, '<>')
  ->orderBy('weight')
  ->orderBy('title')
  ->execute()
  ->fetchAllAssoc('path', PDO::FETCH_ASSOC);

What about something like

<?php
$or
= db_or();
$and_one = db_and()->condition('m.tab_parent', $router_item['tab_root'])
  ->
condition('m.context', MENU_CONTEXT_NONE, '<>')
  ->
condition('m.context', MENU_CONTEXT_PAGE, '<>');
$and_two = db_and()
  ->
condition('m_parent.context', MENU_CONTEXT_NONE, '<>')
  ->
condition('m_parent.context', MENU_CONTEXT_PAGE, '<>');
$or->condition($and_one);
$or->condition($and_two);
$select = db_select('menu_router', 'm')
  ->
fields('m');
$select->innerJoin('menu_router', 'm_parent', 'm_parent.path = m.tab_root');
$select->condition($or);
$select->orderBy('weight')
  ->
orderBy('title')
  ->
execute()
  ->
fetchAllAssoc('path', PDO::FETCH_ASSOC);
?>

#914382: Contextual links incompatible with render cache didn't touch menu_contextual_links() :)

Status:Active» Needs review
StatusFileSize
new677 bytes
FAILED: [[SimpleTest]]: [MySQL] Setup environment: Test cancelled by admin prior to completion.
[ View ]

I spent a good deal of time with this, and I'm not sure if it's possible with a single query.

What we want are all local tasks, and the parent task only when it has a default local task, and only when only none of the local tasks have MENU_CONTEXT_NONE or MENU_CONTEXT_PAGE.
But all parents have MENU_CONTEXT_NONE, and it's hard to know if they have a child MENU_DEFAULT_LOCAL_TASK.

So, this is easier.

However, this is going to break a lot of tests, but all of the ones that break are violating #1995620: [policy, no patch] Document how to handle routes for MENU_DEFAULT_LOCAL_TASK anyway, so we can just fix them.

StatusFileSize
new3.71 KB
PASSED: [[SimpleTest]]: [MySQL] 55,838 pass(es).
[ View ]

Actually, this shouldn't be a big problem. We don't need to change all the asserts, just the contextual link ones.

Status:Needs review» Reviewed & tested by the community

The default local task path is never used AFAIK so if it is used then it's a bug. I wonder whether this is backportable too.

Version:8.x-dev» 7.x-dev
Status:Reviewed & tested by the community» Patch (to be ported)

Committed ace3459 and pushed to 8.x. Thanks!

Let the backport discussion begin :)

Version:7.x-dev» 8.x-dev
Status:Patch (to be ported)» Reviewed & tested by the community

Nice!

Version:8.x-dev» 7.x-dev
Status:Reviewed & tested by the community» Patch (to be ported)

I'm to slow.

Issue tags:-WSCCI

No WSCCI tag needed for D7.