Overridden menu item status lost when menu is saved / synced

Created on 24 October 2016, about 8 years ago
Updated 1 June 2023, over 1 year ago

Problem: Disabling menu link item created by taxonomy menu has no effect.

Example: Lets say i have a taxonomy called "Category". I want to show all categories (CatA, CatB, CatC) except "CatX". When I go to the menu link page and disable the "CatX" link it wont take effect. The "CatX" is still displayed. However links created manually from the Drupal administration can be disabled without any problems.

🐛 Bug report
Status

Needs review

Version

3.0

Component

Code

Created by

🇬🇷Greece ANDiTKO

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇫🇷France goz

    I have the same issue. Here is my way to reproduce.

    1/ Create a term in a vocabulary synced with menu.
    2/ Set term as enabled.
    3/ Menu item is created and enabled.
    4/ Disable term
    5/ Menu item is still enabled

    There is two issues in code :
    1/ In TaxonomyMenu::buildDefinition(), menu link should take care of term status.

    // There is no enabled key here.
    $link += [
          'id' => $this->buildMenuPluginId($term),
          'title' => $term->label(),
          'description' => $term->getDescription(),
          'menu_name' => $menu_id,
          'expanded' => $this->expanded,
          'metadata' => [
            'taxonomy_menu_id' => $taxonomy_menu_id,
            'taxonomy_term_id' => $term_id,
          ],
          'route_name' => $term_url->getRouteName(),
          'route_parameters' => $term_url->getRouteParameters(),
          'load arguments'  => $arguments,
          'parent' => $menu_parent_id,
          'provider' => 'taxonomy_menu',
          'class' => 'Drupal\taxonomy_menu\Plugin\Menu\TaxonomyMenuMenuLink',
        ];
    

    2/ In update, TaxonomyMenuMenuLink::updateLink(), is called with $persist at false. When term is updated, some updates are passed to menu link like title or weight changes, but not status.

    I'll make a MR to make menu link follow term status changes.

  • Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 8
    last update over 1 year ago
    Not currently mergeable.
  • @goz opened merge request.
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 8
    last update over 1 year ago
    4 pass
  • Status changed to Needs review over 1 year ago
Production build 0.71.5 2024