backdrop-issues icon indicating copy to clipboard operation
backdrop-issues copied to clipboard

Warning: Undefined array key "title" in Block->form() line 266 block.class.inc

Open klonos opened this issue 2 years ago • 5 comments

Description of the bug

image

This error is shown in admin/structure/block/list when you have added a custom block on a layout and have made it reusable, but have not saved the layout yet.

Steps To Reproduce

To reproduce the behavior:

  1. Enable all errors in admin/config/development/logging
  2. Go to any layout
  3. Click on "Add block" in any region
  4. Select "Custom block" from the list of blocks
  5. Give the block a title
  6. Tick the "Make this block reusable" checkbox
  7. Provide an admin title and description
  8. Click "Add block", but do NOT save the layout changes yet
  9. Navigate to admin/structure/block/list in another browser tab...

Actual behavior

The above-mentioned error is thrown.

Note: the error is only shown once and then goes away - if you refresh the page, you won't ever see it again, but it is logged in admin/reports/dblog if you don't have errors enabled.

Expected behavior

No error.

Additional information

Add any other information that could help, such as:

  • Backdrop CMS version: 1.27.x-dev
  • Web server and its version: Apache/2.4.56 (Debian)
  • PHP version: 8.1.18
  • Database sever (MySQL or MariaDB?) and its version: 10.3.27-MariaDB
  • Operating System and its version: Lando 3.202 on Mac OS Ventura 13.5.2 (22G91)
  • Browser(s) and their versions: Chrome 117.0.5938.92 (Official Build) (x86_64)

klonos avatar Oct 03 '23 16:10 klonos

...I've gotten the same error also on the admin/structure/layouts/manage/%layout% page, after editing and re-saving a newly-created reusable block (with the layout changes not saved yet). So:

  1. create custom block and make it reusable
  2. save the block but NOT the layout
  3. re-edit the block
  4. re-save the block -> error

image

klonos avatar Oct 03 '23 17:10 klonos

Confirming that this is an issue also with the second set of steps. @NormPlum you provided a PR for another issue that may be related or in the same "area" of Backdrop. Wondering if you might be interested in tackling this one? :)

argiepiano avatar Oct 29 '25 13:10 argiepiano

I don't think this needs a separate PR as the issue is when you leave the Content field empty. If you perform the steps above but also add text to the Content field, the issue doesn't happen.

So if the other PR is committed that'll prevent people submitting the form without Content field and prevent this error.

NormPlum avatar Oct 29 '25 23:10 NormPlum

Actually, that's not the case. The problem still exists even with your PR - it's a different bug. This is what I'm seeing with your other PR applied:

  1. Apply PR (https://github.com/backdrop/backdrop/pull/5141)
  2. Go to Layouts and edit the default layout
  3. On the sidebar, add a custom block. Enter text in the content and leave title empty
  4. Click the checkbox to make the block reusable
  5. Enter an admin label
  6. Save the block but don't save the Layout
  7. Click "Configure" to edit the layout you just created
  8. Click "Update block" (no need to save the Layout)
  9. Go to Reports > Recent log messages

There you'll see the error that was reported in the post. All of this after your PR.

argiepiano avatar Oct 30 '25 00:10 argiepiano

I see. I was adding a block title. But it doesn't seem to be a required field for reusable blocks, so an empty title was causing the error.

I've unlinked the other PR and made a new one for this issue.

NormPlum avatar Oct 30 '25 03:10 NormPlum