Hola,

I've been getting used to doing D8 development by porting a module over to D8 and in doing so, I found a strange bug (? I can only assume its a bug) within the routing system.

So in my module, I have a path (/admin/appearance/manage/google_webfont_loader_api) which is an administrative page within the appearance section.

Webfont loader admin interface.

However, when I first got rid of hook_menu and solely used the routing.yml file, I found out that the 'Google Webfont Loader Settings' tab was now gone (I was able to bring it back by implementing hook_menu again - why both routing and hook_menu are necessary when we used to have solely hook_menu perplexes me but as far as I have been told to accept, "it is what it is"). But last week, I found out that even though the menu item is missing, the route is still accessible. So I went to take a look and I found an interesting result:

Parent menu item (admin/appearance) takes over

(These are just unedited screenshots but I hope it is easy enough to see the different)
The parent item (at admin/appearance) seems to inject some of its own content onto the page (along with setting the menu item tab to 'list'). So while the routing/menu stuff may be intentional, this part of the behavior certainly seems like a bug. I'm happy to help provide any other information as necessary.

CommentFileSizeAuthor
parent-takes-over.png170.98 KBBTMash
goal.png152.31 KBBTMash
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

You should also convert your local task to use the new LocalTask plugin. Then it should probably work.

BTMash’s picture

I'm a bit confused by this...are there any examples of this somewhere (looking through the codebase, I see the localtask tests but that is about it)? Also, the page I have for this currently extends SystemConfigFormBase (since my page is configuration form).

BTMash’s picture

Also, I should note that if I implement hook_menu (and just make it into a menu_callback if I wanted it hidden or set it as menu_local_task for the menu type), then it works as expected (though ideally, I would prefer to avoid implementing hook_menu altogether if possible, even if this wasn't a local task).

dawehner’s picture

At the moment you either go with just hook_menu() based approach, or you just use a route entry + a local task plugin.

Just have a look at
core/modules/views_ui/lib/Drupal/views_ui/Plugin/Menu/LocalTask/ViewsSettingsTask.php
core/modules/views_ui/lib/Drupal/views_ui/Plugin/Menu/LocalTask/ViewsSettingsBasicTask.php
core/modules/views_ui/lib/Drupal/views_ui/Plugin/Menu/LocalTask/ViewsSettingsAdvancedTask.php
core/modules/views_ui/lib/Drupal/views_ui/Plugin/Menu/LocalTask/ViewsListTask.php

pfrenssen’s picture

I encountered this with a subpath that is not a local task, but a regular MENU_CALLBACK. It occurs when deleting a language in the language module. I need to leave this in hook_menu() otherwise the help text, local tasks and local actions are inherited from the parent path admin/config/regional/language.

  $items['admin/config/regional/language/delete/%language'] = array(
    'route_name' => 'language_admin_delete',
  );

I also notice that when I enter a random subpath to a page that contains help texts, local tasks, or local actions, then these are displayed on the resulting 404 page. For example if you go to admin/structure/types/lalala you see the local action "Add content type" on the 404 page.

pfrenssen’s picture

My remark from #5 has been fixed in the meanwhile.

dawehner’s picture

Status: Active » Fixed

That kind of stuff is also fixed in the meantime

Status: Fixed » Closed (fixed)

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