Updated: Comment #N

Problem/Motivation

Local tasks for "Manage display" and "Manage form display" are only visible on Field UI routes

Proposed resolution

Fix \Drupal\field_ui\Access\FormModeAccessCheck and \Drupal\field_ui\Access\ViewModeAccessCheck

Remaining tasks

User interface changes

API changes

Original report by @aspilicious

Look at the screenhots, the tabs change when I click on one of the tabs.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

aspilicious’s picture

Title: Local tasks are incorrect on taxonomy pages » Field UI Local tasks are incorrect on any entity

Happens on any entity apparantly

swentel’s picture

alphawebgroup’s picture

the problem is in object to array conversion in those functions:
entity_get_form_modes()
entity_get_view_modes()

$form_modes[$form_mode_entity_type][$form_mode_name] = (array) $form_mode;
$view_modes[$view_mode_entity_type][$view_mode_name] = (array) $view_mode;
alphawebgroup’s picture

Priority: Normal » Critical
Status: Active » Needs work

i think it's critical issue after #2111823: Convert field_ui / Entity local tasks to YAML definitions is resolved

tim.plunkett’s picture

There's no problem with entity_get_form_modes() or entity_get_view_modes() here.

The problem is in \Drupal\field_ui\Access\FormModeAccessCheck and \Drupal\field_ui\Access\ViewModeAccessCheck

When on a path like admin/structure/types/manage/article/display, it uses the route from \Drupal\field_ui\Routing\RouteSubscriber, which has the 'entity_type' added to the $defaults. But when on a module defined route like admin/structure/types/manage/article, it does not have the entity type specified, and those access checks fail immediately.

tim.plunkett’s picture

Issue summary: View changes
Status: Needs work » Active
alphawebgroup’s picture

@tim.plunkett
it fails on any path after the cache flushing
also, it sets a wrong cache value to "entity_view_mode_info:en"

a:5:{s:7:"comment";a:1:{s:4:"full";a:12:{s:2:"id";s:12:"comment.full";s:4:"uuid";s:36:"06ab5b16-e197-4242-b72c-4453793fabba";s:5:"label";s:12:"Full comment";s:16:"targetEntityType";s:7:"comment";s:6:"status";b:0;s:5:"cache";b:1;s:13:"

that value wouldn't be unserialized next time

alphawebgroup’s picture

ahhh, yep, understood...
please ignore my #7 comment

swentel’s picture

Status: Active » Needs review
FileSize
1.61 KB

This fixes it for content types, accounts and taxonomy vocabularies.

tim.plunkett’s picture

That's one way to fix that, but how would you know to do that? Only Field UI needs it.

swentel’s picture

FileSize
1.5 KB

Right, different approach, works fine too.

tim.plunkett’s picture

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

That is *much* better! Now we just need tests.

swentel’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
677 bytes
2.17 KB
amateescu’s picture

Status: Needs review » Reviewed & tested by the community

The test and the fix looks good, sorry for breaking this :)

dawehner’s picture

This fix makes totally sense.

The last submitted patch, 13: 2142553-12-test-only.patch, failed testing.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Nice catch!

Committed and pushed to 8.x. Thanks!

Status: Fixed » Closed (fixed)

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