Incorrect validation leading to invalid cloned types.

Created on 13 April 2021, over 3 years ago
Updated 6 April 2023, almost 2 years ago

Problem/Motivation

Currently this module uses a textfield to represent the machine name, and uses the form validation function to ensure that the target entity type machine name doesn't already exist. The MachineName form element used by entity type creation forms does a little more then that though. It also ensures that the machine names only contain certain characters. As it's setup right now, the module will allow machine names that contain invalid characters. This prevents you from updating the entity in the future, since it will no longer save via the admin edit screen for the entity type. I'm marking it as Critical because if you don't catch it before content authors create content using that type, the only way to correct it is via database scripts or deleting the entity type and recreating all the content.

Steps to reproduce

I'll use a paragraph as an example, but it works with any entity.

  1. Clone an existing paragraph with a machine name of "invalid-machine-name".
  2. Navigate to /admin/structure/paragraphs_type/invalid-machine-name
  3. Update something on that page, such as the description
  4. Click Save.

The form will generate an error of "The machine-readable name must contain only lowercase letters, numbers, and underscores. "

Proposed resolution

Change the clone_bundle_machine form element from a textfield to a machine_name element, which takes care of all the validation for you. Attached patch does that.

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇺🇸United States jacobbell84

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024