Skip to content

Pre-existing field with reserved entity machine name re-used on entity type causes fatal error when adding entity #6900

@yorkshire-pudding

Description

@yorkshire-pudding

Description of the bug

Backdrop does a great job of preventing use of field_name machine name for new fields once Paragraphs is installed, whether for paragraph types or for nodes. However, if you've already created a field with machine name of field_name then you are not prevented from re-using that field on a paragraph type.

This was first raised in the paragraphs issue queue but actually is wider

Steps To Reproduce

To reproduce the behavior:

  1. Start with a site without Paragraphs
  2. Add a field to a content type with label of "Name" and allow the field machine name to be saved as field_name
  3. Install Paragraphs
  4. Create new paragraph type
  5. Add the field_name field to the paragraph type
  6. Add a paragraphs field to a content type
  7. Create a new item of that content type
  8. Enter some data (not paragraph) and save
  9. Re-edit and add the paragraph
  10. Save the node

Actual behavior

Fatal error:

TypeError: Cannot access offset of type string on string in _field_invoke() (line 193 of /var/lib/tugboat/backdrop/core/modules/field/field.attach.inc).

Image

Expected behavior

Node saves, but actually, re-using an existing field with field_name on a paragraph type should be prevented at Step 5

Image
Screenshot from PR change

Additional information

Add any other information that could help, such as:

  • Backdrop CMS version: 1.30.2
  • Web server and its version: n/a
  • PHP version: n/a
  • Database sever (MySQL or MariaDB?) and its version: n/a
  • Operating System and its version: n/a
  • Browser(s) and their versions: n/a

PR: backdrop/backdrop#5072

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions