Skip to content

Conversation

@andybroomfield
Copy link
Contributor

@andybroomfield andybroomfield commented Nov 24, 2025

Fix #307
Fix #140

What does this change?

Rename the menu localgov_services_menu to use hypens as in localgov-services-menu
Need to check if this is actually used in places apart from config and if other modules (localgov_demo) or themes (localgov_base) need to be updated to account for the change.

How to test

Go to /admin/structure/menu/manage/localgov_services_menu and save the menu.
(Requires fresh install).

How can we measure success?

No more errors when trying to edit the services menu with

"The machine-readable name must contain only lowercase letters, numbers, and hyphens."

Have we considered potential risks?

Menu name is used in places independently (custom themes).

Images

n/a

Accessibility

n/a

@andybroomfield
Copy link
Contributor Author

@andybroomfield
Copy link
Contributor Author

I've updated block configuration here, there are some code changes to Localgov_demo that will need to be carried out and merged at the same time if we decide to go with this.

I couldn't find any references in localgov_base. If I've missed something @markconroy it would be good to check the theme can still work with this change.

I haven't made an update hook. Is that something we require for this change or are we happy it's new sites only. Presumably most who have run into the issue have done what BHCC did and create our own menu a long time ago so it's not relevant.

@andybroomfield
Copy link
Contributor Author

It appears as long as the menu name is localgov-services-menu then the magic services menu in localgov_base continues to work.
Screenshot 2025-11-24 at 3 26 41 pm

@markconroy
Copy link
Member

@andybroomfield I think I'd like an update hook for this (maybe as a follow up if we wish) but it definitely seems to be a bug that we have that we should fix across the board.

@tonypaulbarker
Copy link
Contributor

Some thoughts on supporting existing sites.

I’m not sure we can do update hooks because we won’t know the naming for the active theme block config? Is it possible that theming overrides can depend on the underscores too?

One idea is a snippet to bypass Drupal core’s validation for that specific machine name?

… link content

This will
- Create the new menu, `localgov-services-menu`
- Update menu_link_content entities (user created menu items) to set the menu name
  to `localgov-services-menu` from `localgov_services_menu`
- Delete the old menu `localgov_services_menu`
@andybroomfield
Copy link
Contributor Author

@markconroy @tonypaulbarker I've pushed an update hook for review. I only think I can update the machine name of the menu by creating a new one and moving the items over. But any other configuration I'm not so sure about in terms of how we go about it. Would we have to discover each block and then try and update them, and would it effect a theme.

@finnlewis
Copy link
Member

I'm also testing.

@finnlewis
Copy link
Member

Just fixed some coding standards so the rest of the tests can run.

@finnlewis
Copy link
Member

Update hook works nicely for me @andybroomfield

Before:
image

after:
image

Copy link
Member

@finnlewis finnlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me! :)

@finnlewis
Copy link
Member

finnlewis commented Nov 25, 2025

Discussing in Merge Tuesday:

For existing sites block placements is an issue, attempting to delete the old menu will remove the block placement.

Andy suggests we create the menu, copy links to the new menu but don's delete the old menu.

Add rerelease notes to be clear that developers need to:

  1. remove the old menu block, place the new menu block.
  2. update any other code that references the menu block name.
  3. delete the old menu

In order to prevent existing sites breaking
- Check if an existing `localgov-services-menu` exists, and abort if so.
- Duplicate menu content items instead of moving them.
- Relabel the existing `localgov_services_menu` indicating it should be
  deleted once the blocks have been replaced.
@finnlewis finnlewis requested a review from AWearring November 25, 2025 12:53
Copy link

@AWearring AWearring left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on the West Lindsey build where we had already "fixed" the issue by renaming the menu via a patch. localgov_services happily updated and the update hook gets skipped because of if ($existing).

Will try testing on a new LGD vanilla build later

Copy link

@AWearring AWearring left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have no tested on an old LGD vanilla build I had locally and the update hook correctly copies the Services Menu and updates the existing menu to make it obvious that it should be removed
image

@andybroomfield
Copy link
Contributor Author

This PR has been recreated on Drupal.org
https://git.drupalcode.org/project/localgov_services/-/merge_requests/3
Please merge there and close this PR.

@andybroomfield
Copy link
Contributor Author

Should we close the PR here as merged on Drupal.org?

@finnlewis
Copy link
Member

This is merged on drupal.org https://git.drupalcode.org/project/localgov_services/-/merge_requests/3

Cosing here

@finnlewis finnlewis closed this Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Services menu: The machine-readable name must contain only lowercase letters, numbers, and hyphens. Service menu id

6 participants