Menu machine names - additional validation - prevent mistakes

Created on 12 April 2024, about 1 year ago
Updated 24 April 2024, about 1 year ago

Problem/Motivation

When you create a menu, you can add spaces or uppercase letters to the machine name and the menu will be created.

Steps to reproduce

1. Go the Menus, and click on Add menu,
2. Set the title and you will see the machine name proposed,
3. Click on Edit (to edit the machine name),
4. Add spaces or uppercase letters to the new machine name,
5. Save and the new menu will be created.

6. Go back to the Menu list and the menu will be there.

Illustrations:

when "dummies do this", lots of lots of errors and a messy cleanup is required.

Dummy step 1)

  • From /admin/structure/menu/add enter a menu title

Illustration of Dummy step 1:

Dummy step 2)

  • press the edit link for machine name, manually replace the underscores with spaces.

Illustration of Dummy step 2:

Dummy step 3)

  • Press save

The result is a mess that needs a database restore from backup or some tricky work outside of the drupal api to clean it up.

Suggested solution:

  • Add submit validation handling for these machine names to prevent dummies from breaking stuff.

Proposed resolution

You should not be able to create a new menu if the machine name dont fill the requirements.

🐛 Bug report
Status

Closed: works as designed

Version

11.0 🔥

Component
Menu system 

Last updated 1 day ago

Created by

🇨🇦Canada jcninov

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024