TypeError: Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay::save(): Return value must be of type int, null returned

Created on 16 July 2024, about 2 months ago
Updated 1 August 2024, about 1 month ago

Problem/Motivation

The following error is triggered when trying to create a field using the drush field:create command:

[error]  TypeError: Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay::save(): Return value must be of type int, null returned in Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay->save() (line 172 of /Users/dieterholvoet/Projects/sites-personal/whathappens/web/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php) #0 /Users/dieterholvoet/Projects/sites-personal/whathappens/vendor/drush/drush/src/Commands/field/FieldCreateCommands.php(494): Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay->save()
#1 /Users/dieterholvoet/Projects/sites-personal/whathappens/vendor/drush/drush/src/Commands/field/FieldCreateCommands.php(200): Drush\Commands\field\FieldCreateCommands->createFieldDisplay('view')
#2 [internal function]: Drush\Commands\field\FieldCreateCommands->fieldCreate('node', 'social_post', Array)

The problem is that LayoutBuilderEntityViewDisplay::save() assumes that EntityInterface::save() always returns an int, but in practice it can return NULL as well.

Proposed resolution

Remove the return type.

🐛 Bug report
Status

Needs review

Version

1.0

Component
Layout builder 

Last updated 1 minute ago

Created by

🇧🇪Belgium DieterHolvoet Brussels

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024