Experiencing weird behaviour with migrated menu items.
I have a migration script that runs after installation which adds a link to the contact form (/contact path).
In the database this appears as menu_tree.url = 'base:contact' instead of menu_tree.route_name = 'contact.site_page'.
After a manual cache clear (in the UI, note: doesn't work with drush cr..), the route_name is magically filled in to 'contact.site_page'.
This migration of menu items used to work in Drupal 8.1 but is broken in 8.2.
The links appear but they aren't indicated as active. In the database route_name is empty (should be "contact.site_page") and route is "base:contact".
The csv source:
id;language;menu_name;link_title;link_path;description;external;weight;expanded;enabled;options
1;en;secondary-navigation;"Contact us";contact;"";0;0;1;1;
2;en;secondary-navigation;"FAQ";faq;"";0;1;1;1;
3;en;footer;"External link";"http://drupal.org/";"";1;0;1;1;
4;en;footer;"Contact us";contact;"";0;1;1;1;
The migrate yaml:
source:
plugin: csv
default_lang: true
path: private://migrate/custom/menu_links_paths.csv
delimiter: ;
enclosure: '"'
escape: "\\"
header_row_count: 1
keys:
- id
column_names:
0:
id: Id
1:
language: Language code
2:
menu_name: Menu name
3:
link_title: Link title
4:
link_path: Path
5:
description: Description
6:
external: External
7:
weight: Weight
8:
expanded: Expanded
9:
enabled: Enabled
10:
options: Options
11:
route_name: Route name
destination:
plugin: entity:menu_link_content
default_bundle: menu_link_content
no_stub: true
translations: true
process:
langcode: language
title: link_title
description: description
menu_name: menu_name
options_source:
plugin: explode
source: options
delimiter: ,
'link/uri':
plugin: link_uri
source:
- link_path
'link/options': options
route:
plugin: route
source:
- link_path
- options
route_name: route_name
route_parameters: '@route/route_parameters'
url: '@route/url'
options: '@route/options'
external: external
weight: weight
expanded: expanded
enabled: enabled
destination:
plugin: entity:menu_link_content
default_bundle: menu_link_content
no_stub: true
migration_dependencies:
required:
- menu
Comments
Comment #2
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedComment #3
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedNot a duplicate of https://www.drupal.org/node/2707387.
Comment #4
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedComment #5
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedComment #6
skuark CreditAttribution: skuark commentedExperiencing the exact same issue that mpp reports: menu links migration working with 8.1.x not working properly after update to 8.2.x. Clearing cache from UI, not with drush, fixes the problem.
If you look at the table
menu_tree
before and after clearing caches with UI, you can see some differences: https://gist.github.com/skuark/2f5b4a2bfb092274178a32ef1ead0700Comment #7
mpp CreditAttribution: mpp as a volunteer and at AmeXio commented@skuark: do you have any patches applied, what version of Drush do you have?
In my case I had Drush Version 8.1.5, I recently updated to 8.1.7 which seems to have resolved the issue.
Comment #8
skuark CreditAttribution: skuark commented@mpp: I have one patch for the metatag module (https://www.drupal.org/files/issues/metatag-deactivate_drupalconsole_ser...), but nothing related to that.
I had Drush 8.1.2. I've tested again with Drush 8.1.7 but the problem persists. Anyway, now with drush 8.1.7 the cache clearing is working properly, but with Drupal 8.1.x I didn't need to clear caches after migration.
Comment #13
heddnIs this still an issue?
Comment #14
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedThis is no longer an issue.