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.