The Problem
After you have made a menu branch using the module erratic random behaviour can occur on cache flush or term saving. Most specifically the weights become normalised to 0 and the menu items then reset to alphabetical order. This is on the dev release which even sets the weight to the weight of the term.
'weight' => $term->getWeight(),
The problem eventually comes in when you load up the menu and do a transform on the items.
$manipulators = [
['callable' => 'menu.default_tree_manipulators:checkAccess'],
['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'],
];
return $this->menuLinkTree->transform($tree, $manipulators);
The generateIndexAndSort then calls up the menu item weight which looks at the pluginDefinition['weight'] which is not being correctly set or saved. Thus it returns 0 and sets the pluginDefinition['weight'] also to 0 so now your menu is permanently re-ordered.
To recreate
1) Create a multi branch vocabulary
2) Add items in reverse alpha order to the vocabulary (z-a)
3) Create the taxonomy in the menu using the module.
4) In a menu factory service call up the menu and transform it using "generateIndexAndSort"
Then play
- Rearrange the items in the menu, then flush cache.
- Rearrange the items in the originating taxonomy flush cache.
- Do either of these and then resave the taxonomy menu entry.
- Edit a term and resave it. Flush cache.
The most noticable one is when you edit a term and resave it. This blows out the "pluginDefinition['weight']" and causes all the items in the menu then to have a default weight of 0. So when you do a "indexAndSort" on the menu items they will sort alphabetical.
Final Thoughts
I believe the problem is that the module is not making true content entity links. Instead it is making some sort of hybrid menu links and these links are subject to resets and flush cache issue.
Current Solution
At present we are instead using the "Simple Taxonomy Module" (stm). This is creating stand alone regular links in the menus that have to be ordered and resync however they do not jump or reset.
Comment | File | Size | Author |
---|---|---|---|
#16 | menu_order_reset-2861460-16.patch | 571 bytes | miiimooo |
| |||
#6 | menu-order-reset-2861460-6.patch | 418 bytes | mirom |
|
Comments
Comment #2
szantog CreditAttribution: szantog as a volunteer commentedA pretty ugly workaround:
Comment #3
dkre CreditAttribution: dkre commentedRan into the same issue. Drupal 8.3.7 and 8.3.3
I would see the term weight reset on saving a term without a cache flush.
Here's my workaround:
Comment #4
mirom CreditAttribution: mirom at Cheppers for Acquia commentedI was able to reproduce this problem on current 8.x-3.x-dev release. Working on fix. Meanwhile I can confirm that before-mentioned approaches fix the issue.
Comment #5
mirom CreditAttribution: mirom at Cheppers for Acquia commentedComment #6
mirom CreditAttribution: mirom at Cheppers for Acquia commentedI think that this patch works for me, worth testing. It allows plugin manager to override also parent with incoming value.
Comment #8
dstolComment #10
Lukas von BlarerI had this issue again on a 8.4.x install. After updating to 8.5.x everything worked fine.
Comment #11
rgeerolfI still have this problem with the latest dev and Drupal 8.5.1 so maybe it's not entirely fixed?
Comment #12
Lukas von BlarerIn my case this was only resolved by installing updates. Do you want to create a follow-up issue?
Comment #13
rgeerolfBy installing updates, you mean by updating to the latest stable from Drupal Core?
Comment #14
zepner CreditAttribution: zepner at Aten Design Group commentedI tried the most basic use-case for this module and the issue remains in 8.x-3.x.
Configs have been locked down, but a cache refresh still wipes the menu weights rendering a mess.
Unusable, unless I'm missing something.
Comment #15
miiimoooI've investigated this issue and I think it's down to (stale or old) static menu overrides. This also explains that the symptoms can vary from site to site.
The quickfix is:
UPDATE `config` SET `name` = 'RENAMED.core.menu.static_menu_link_overrides' WHERE `config`.`collection` = '' AND `config`.`name` = 'core.menu.static_menu_link_overrides';
Which removes all static menu overrides!!
After that you can do a cache rebuild and everything is still the same.
Problem solve.. not really but maybe it's a good starting help for someone else.
Could a maintainer re-open this issue?
UPDATE: Actually this was an old configuration file (a menu override..)
Comment #16
miiimoooAttached is a patch that makes it possible to Reset Taxonomy-menu-based menu items (see previous comment) in the menu overview page.
Comment #17
andrey.troeglazov CreditAttribution: andrey.troeglazov at DrupalJedi commentedComment #18
WalkingDexter CreditAttribution: WalkingDexter at Initlab commentedThe solution from #2 does not work for me.
I use the event subscriber.
Comment #19
sittard CreditAttribution: sittard commentedJust ran into this issue. It looks like this code has been committed to the dev branch of this module (https://www.drupal.org/commitlog/commit/230/1103ad0855de4d242364a5b7e74a...) and that seems to be working better for me but we are still experiencing issues with the menu weights being reset when the cache is flushed on Drupal 8.6.x.
Comment #21
dstolThanks for the contribution!
Comment #23
DamienMcKenna