Problem/Motivation
Using drush 11 and drupal 9.3.16. import(force) the Administration menu items are not enabled.
Steps to reproduce
- export the Administration menu
- import(force) the Administration menu
Proposed resolution
When I exported the structure_sync.data.yml file I found that the enable and expanded field value are true or false
enabled: true
expanded: false
But in the MenuLinksController.php, the logic is:
'expanded' => $menuLink['expanded'] === '1' ? TRUE : FALSE,
'enabled' => $menuLink['enabled'] === '1' ? TRUE : FALSE,
So the enabled and expanded will be FALSE forever.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 3285551-4.patch | 2.74 KB | narendra.rajwar27 |
| #2 | 3285551-1.patch | 5.48 KB | zhangjy |
Issue fork structure_sync-3285551
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
zhangjy commentedComment #3
louis-cuny commented1. We can remove the stupid "? TRUE : FALSE".
2. We should check previous versions where "1" was used and try both solutions: in_array($menuLink['expanded'], ['1', TRUE], TRUE)
Comment #4
narendra.rajwar27Updating patch as suggested in comment #3
Since the patch in comment #2 is not getting applied, so could not create Inter-diff file.
Comment #6
louis-cuny commentedComment #8
chrisckTested path #4 and it is working. Administration menu items are enabled on import.
Comment #9
xamountThe patch at #4 also solved the issue for me.
In my case, I exported menus locally as I usually would, but when I deployed and imported using drush im (full), the menus items exist, but they are always disabled. With the patch, it now works as expected (menu items exists and are enabled if they were set so).
Setting the priority to "Critical" as the drush im is basically broken without this patch.
For those interested in correctly exporting menus locally and then importing on production, here are the steps:
In typical deployments, drush updb is usually run first, so you can write a hook_update like this:
This will import your config first, then import your menus. So then you do not need to manually run drush im on production.
Basically you need to run drush cim first because it will import the structure_sync config. Only then you can run drush im.
(Change 9007 to match your hook_update numbering)
Comment #10
louis-cuny commentedComment #13
louis-cuny commentedThanks for the reviews !