Problem/Motivation

Error on `drush updatedb`

> [notice] Update started: block_post_update_set_menu_block_depth_to_null_if_zero
> PHP Fatal error: Declaration of Drupal\layout_builder_kit\Plugin\Block\LBKBaseComponent::submitConfigurationForm(array &$form, Drupal\Core\Form\FormStateInterface $form_state) must be compatible with Drupal\Core\Block\BlockBase::submitConfigurationForm(array &$form, Drupal\Core\Form\FormStateInterface $form_state): void in /var/www/drupal/web/modules/contrib/layout_builder_kit/src/Plugin/Block/LBKBaseComponent.php on line 311
> [warning] Drush command terminated abnormally.

Steps to reproduce

Update to drupal 11.2 with layout_builder_kit 3.0-beta installed

Proposed resolution

Adding the return type to the function seems to work

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

cpigott created an issue. See original summary.

sethhill made their first commit to this issue’s fork.

  • aangel committed 2280f630 on 4.0.x
    Issue #3531242: Add : void return type to submitConfigurationForm()
    
aangel’s picture

Status: Active » Fixed

Fixed on both branches.

Root cause: Drupal core declared BlockBase::submitConfigurationForm(): void in
11.2.0, which made LBKBaseComponent's untyped override a fatal error at class
load — hence the failure during drush updatedb. Core reverted that return type
in 11.3.0, so the fatal is specific to Drupal 11.2.x; 11.3+, 11.4 and 12.0-dev
declare no return type.

The fix is to declare the return type on our side. PHP permits a child to add a
return type where the parent declares none, so ': void' is valid against Drupal
10, 11 and 12 alike, and it keeps us correct if core reintroduces the type.
LBKBaseComponent is the only class in the module declaring this method, so no
other changes were needed. I also confirmed no other BlockBase or
BlockPluginTrait method overridden by this module gained a return type in 11.2.

3.0.x: commit 039cb78 — thanks to Seth Hill for the patch. His MR !9 was rebased
onto current 3.0.x before landing, because its branch predated the fix for
#3459820 and would otherwise have reverted it.

4.0.x: commit 2280f63 via MR !12, verified green against Drupal 12.0-dev on
PHP 8.5.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.