Skip to content

Fixed fatal error when creating Reusable Custom Blocks with duplicate machine names. #6912

@alanmels

Description

@alanmels

Description of the bug

When using the Reusable Custom Blocks module (part of Backdrop core), creating two custom blocks with the same machine name causes a fatal error due to improper handling of duplicates in the database.

Actual behavior

1. Enable the Reusable Custom Blocks module on a fresh Backdrop install.
2. Create a new custom block and give it a specific machine name (e.g., my_block).
3. Create another custom block and manually enter the same machine name (my_block).
4. See the error:
TypeError: Cannot access offset of type array on array in block_custom_block_load() (line 225 of /var/www/html/docroot/core/modules/block/block.module).     

Expected behavior

The system should validate the uniqueness of the machine_name and prevent creation of blocks with duplicate machine names.

Additional information

The block_custom_block_load() function expects machine_name to be unique, but the database does not enforce this. When duplicates exist, the query returns multiple rows and attempts to treat them as a single array, resulting in a TypeError.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions