---
title: "Menus disappear intermittently with menu_item_extras version 3.1.2"
date: "2026-08-18T20:34:01+00:00"
summary: "Fix disappearing Drupal menus caused by a menu_item_extras 3.1.2 cache bug. Diagnose, apply the workaround, and protect users from cross-user menu data."
image:
type: "article"
url: "/acquia-cloud-platform/help/99101-menus-disappear-intermittently-menuitemextras-version-312"
id: "60972dc2-8a93-4da2-a134-5f741db447ad"
---

Warning

This issue affects only version 3.1.2 of the `menu_item_extras` module. Authenticated users on affected sites can access cached menu content that belongs to other users. Treat this as a security-sensitive regression and apply the workaround as soon as possible.

Summary
-------

Version 3.1.2 of the `menu_item_extras` Drupal contributed module introduced a defective render array caching layer in `MenuLinkTreeHandler::getMenuLinkItemContent()`. This regression causes two distinct bugs: a PHP serialization fatal error that prevents the system from writing the menu cache, and cross-user cache reuse caused by missing `theme` and `user.permissions` cache contexts. Neither bug existed in version 3.1.1.

Symptoms
--------

Sites affected by this regression typically display one or more of the following symptoms:

*   Navigation menus disappear intermittently from the front end. Running `drush cr` restores them temporarily, but the problem returns after a short time.
*   PHP error logs contain fatal errors referencing a serialization failure in the context of `menu_item_extras` or `MenuLinkTreeHandler`.
*   Authenticated users access menu links that do not match their role or permissions. 
*   Memcache eviction statistics show an unusually high rate of writes followed by immediate misses on menu-related cache keys.

Affected Versions
-----------------

Module

Affected Version

Safe Version

drupal/menu\_item\_extras

3.1.2

3.1.1 (or a future 3.1.3+ release when available)

Cause
-----

The 3.1.2 release added a render array caching layer to `MenuLinkTreeHandler::getMenuLinkItemContent()`. This implementation contains the following two bugs:

*   **Serialization fatal:** The render array contains an object that PHP cannot serialize. When Drupal's cache backend, particularly a persistent backend such as Memcache or database, attempts to store the rendered menu output, the system throws a `PHP Fatal error: Serialization of ... is not allowed`. In some cache backend configurations this failure is caught silently, causing every menu cache write to fail without a visible error in the browser.
*   **Missing cache contexts:** The `#cache` definition on the render array omits the `theme` and `user.permissions` cache contexts. As a result, the system can retrieve and serve a cached menu entry that was created for one user or active theme to a different user with different permissions or to a request that uses a different theme, without triggering a cache miss or a rebuild.

Diagnostic Steps
----------------

To confirm that this issue causes menu problems on your site, complete the following steps:

### Step 1: Confirm the installed module version

Run either of the following commands and confirm the output displays version 3.1.2.

    drush pm:list --filter=menu_item_extras

    composer show drupal/menu_item_extras

If the installed version is not 3.1.2, this issue is not the cause of the problem. Proceed with other cache debugging resources listed under **Related Resources**.

### Step 2: Inspect the menu cache bin

Run the following command to check whether a menu link entry exists in the `cache_menu` bin. Replace `1` with the numeric ID of a known menu link content entity on your site. It is visible in the URL when editing the menu link at **Structure** \> **Menus**.

    drush php:eval "
    \$mid = 1;
    \$menu_link = \Drupal::entityTypeManager()
      ->getStorage('menu_link_content')
      ->load(\$mid);
    if (!\$menu_link) {
      print 'Menu link entity not found in DB. Check the ID.' . PHP_EOL;
    } else {
      print 'DB entity found: ' . \$menu_link->getTitle() . PHP_EOL;
      \$cid = 'menu_link_content:' . \$menu_link->uuid();
      \$cache = \Drupal::cache('menu')->get(\$cid);
      if (\$cache) {
        print 'Cache entry EXISTS for CID: ' . \$cid . PHP_EOL;
        print 'Tags: ' . implode(', ', \$cache->tags) . PHP_EOL;
      } else {
        print 'NO cache entry found for CID: ' . \$cid . PHP_EOL;
        print 'Confirmed: DB entry is intact but cache entry is missing.' . PHP_EOL;
      }
    }
    "
    

If the database entity is found but no corresponding cache entry exists, this confirms the serialization fatal is preventing the cache write.

If a cache entry does exist, examine its `tags` output. If neither `theme` nor `user.permissions` context values appear in the entry's cache ID or tags, the missing cache contexts bug is present.

### Step 3: Force cache tag invalidation for a specific menu

Run the following command to invalidate all cache entries tagged to the main and footer menus and force a rebuild on the next request. Adjust the menu names to match the menus on your site.

    drush php:eval "
    use Drupal\Core\Cache\Cache;
    \$tags = [
      'config:system.menu.main',
      'config:system.menu.footer',
      'config:system.menu.account',
    ];
    Cache::invalidateTags(\$tags);
    print 'Cache tags invalidated for: ' . implode(', ', \$tags) . PHP_EOL;
    print 'Menus will rebuild on the next page request.' . PHP_EOL;
    "
    

After you run this command, if menus display temporarily and then disappear within a few page requests, the serialization fatal error prevents stable cache writes. You must apply the workaround in the following section.

### Step 4: Search PHP error logs for serialization fatals

Search the PHP error log for fatal errors related to `menu_item_extras`. On Cloud Platform, PHP error logs are located at `/var/log/php/php-errors.log`. Run the following command from an SSH session:

    grep -i "serialize\|MenuLinkTreeHandler\|menu_item_extras" /var/log/php/php-errors.log | tail -50

Entries resembling the following confirm the serialization fatal:

    PHP Fatal error: Uncaught Exception: Serialization of
    'Drupal\menu_item_extras\MenuLinkTreeHandler' is not allowed
    in .../core/lib/Drupal/Core/Cache/DatabaseBackend.php on line ...

### Step 5: Review Memcache eviction statistics (if applicable)

If the site uses Memcache as the cache backend, a high eviction rate on the `cache_menu` slab can indicate that menu cache writes are failing or producing large objects that are immediately evicted.

Access the Memcache statistics page at **/admin/reports/memcache** in the Drupal admin UI. Compare the ratio of **evictions** to total **get\_hits**. A high eviction rate specifically on menu-related slabs is consistent with the serialization failure in this bug.

For additional Memcache diagnostics, refer to [Memcache monitoring and flush using the nc command](https://docs.acquia.com/acquia-cloud-platform/help/92951-memcache-monitoring-and-flush-using-nc-command) and [Tuning your Memcached settings](https://docs.acquia.com/acquia-cloud-platform/tuning-your-memcached-settings).

Workaround
----------

Note

This workaround pins the module to version 3.1.1. Confirm that version 3.1.1 is compatible with the site's installed version of Drupal core before proceeding. You can verify compatibility at [drupal.org/project/menu\_item\_extras](https://www.drupal.org/project/menu_item_extras).

1.  Open the `composer.json` file at the root of the Drupal project.
2.  Locate the `require` section and update the version constraint for `drupal/menu_item_extras` to pin it to version 3.1.1:
    
        "drupal/menu_item_extras": "3.1.1"
    
    For guidance on pinning Composer packages, refer to [Migrating a Drupal website into a Composer-managed build](https://docs.acquia.com/acquia-cloud-platform/migrating-drupal-website-composer-managed-build).
    
3.  Save the file and run the following command to downgrade the module and update its dependencies:
    
        composer update drupal/menu_item_extras --with-dependencies
    
4.  Rebuild the Drupal cache to remove any corrupted entries written by version 3.1.2:
    
        drush cr
    
5.  Confirm the downgrade was successful:
    
        drush pm:list --filter=menu_item_extras
    
    The output must display version 3.1.1.
    
6.  Reload the site front end and verify that menus display correctly for both anonymous and authenticated users across multiple roles.

Status
------

Currently, no fix is available in the `menu_item_extras` module at this time. A corrected release (3.1.3 or later) has not yet been published. The upstream bug report is tracked at [drupal.org/project/menu\_item\_extras/issues/3615084](https://www.drupal.org/project/menu_item_extras/issues/3615084). Monitor that issue for patch availability and a corrected release.

Once a fixed version is released, remove the version pin from `composer.json` and run the following commands to upgrade and clear the cache:

    composer update drupal/menu_item_extras --with-dependencies
    drush cr

Related Resources
-----------------

*   [Dynamic Cache Debugging Playbook](https://docs.acquia.com/acquia-cloud-platform/help/97261-dynamic-cache-debugging-playbook)
*   [How does Drupal page cache work?](https://docs.acquia.com/acquia-cloud-platform/help/93426-how-does-drupal-page-cache-work)
*   [Memcache monitoring and flush using the nc command](https://docs.acquia.com/acquia-cloud-platform/help/92951-memcache-monitoring-and-flush-using-nc-command)
*   [Tuning your Memcached settings](https://docs.acquia.com/acquia-cloud-platform/tuning-your-memcached-settings)
*   [Upstream issue: menu\_item\_extras 3.1.2 caching regression (drupal.org)](https://www.drupal.org/project/menu_item_extras/issues/3615084)