Menu link content changes are not visible on non-live workspaces

Created on 14 March 2019, over 5 years ago
Updated 10 July 2023, over 1 year ago

Problem

Now that #2880152: Convert custom menu links to be revisionable β†’ is in, changes to menu links in non-live workspaces are not showing up. Making changes, and publishing changes from non-live to live works well. But it's not possible to preview the changes on the site's frontend.

This is caused by the menu tree cache, because rendered menus needs to be cached per workspace.

The basic problems, which are solved in the current patch are as follows:

  1. Menu links are discovered and stored in the menu_tree table. The MenuTreeStorage service caches a menu's links with a cid which contains all the parameters used in the SELECT query to load the links from the mentioned menu_tree table. This happens inside MenuTreeStorage::loadTreeData(). If we want to see workspace specific links in a tree, the cached tree data needs to be workspace specific and to achieve this we need to override the tree storage in order to make the cid workspace specific. If we don't do that, a cached menu tree saved inside a workspace can and would be retrieved in the live workspace and would possibly show menu link contents (incl. link targets) that are not actually available on the live version of the site.
  2. The DB table menu_tree is not an entity table, thus it's not "revisionable" and hence can't be workspace specific. This table contains columns like "title" and "description" (and possibly others), which are also available on the `menu_link_content` entity. The values from the menu_link_content entity are in fact written/copied into the table at MenuLinkContent::postSave() . In order to implement workspace specific menu links, we have to be loading title and description etc. from menu_link_content revisions in a workspace, so we can't use the title, description etc. that is normally loaded by the MenuTreeStorage::loadLinks() method directly from the DB table. In order to tackle this, we have to overwrite that method, load the links from the DB first (via the original storage's method) and then override those links with what is stored in the workspace specific menu_link_content revisions.

Proposed solution

Cache menus per workspace.

We also have to overwrite certain menu link values loaded in the MenuTreeStorage::loadLinks() as these values come directly out of the menu_tree table and are NOT workspace-specific nor contain values of the menu_link_content entity revisions.

API changes

None.

πŸ› Bug report
Status

Fixed

Version

10.1 ✨

Component
WorkspacesΒ  β†’

Last updated about 6 hours ago

No maintainer
Created by

πŸ‡«πŸ‡·France dixon_ France

Live updates comments and jobs are added and updated live.
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.

Production build 0.71.5 2024