MenuTreeStorage shouldn't invalidate cache tags if the menu didn't change

Created on 1 November 2024, 13 days ago

Problem/Motivation

While debugging an issue with a menu cache tag I noticed that the tags will be invalidated even if the menu didn't change. As menus are usually used on most pages on the site this can result in a large number of invalidations in the CDN for no reason. MenuTreeStorage::doSave already checks to see if the menu item changed, so we can leverage this information to only clear the cache tags if it did.

Steps to reproduce

Set a conditional breakpoint in CacheTagsInvalidator::invalidate for the config:system.menu.main cache tag. Save the menu without changing anything, and the cache tag will be invalidated.

Proposed resolution

Only save if it has changed.

Remaining tasks

User interface changes

N/A

Introduced terminology

N/A

API changes

Changing the return value of MenuTreeStorage::doSave to return a boolean value instead of the menu name in the array. Currently it returns an associative array like main => main. Change to main => TRUE. This is a protected method so should be ok to change as it's internal?

Data model changes

N/A

Release notes snippet

πŸ“Œ Task
Status

Active

Version

11.1 πŸ”₯

Component

menu system

Created by

achap πŸ‡¦πŸ‡Ί

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024