Call to a member function getRegions() on null on database update hooks 91001 and 91002

Created on 22 August 2023, about 1 year ago
Updated 24 August 2023, about 1 year ago

We're getting the following error when running drush updb on both layout_paragraphs_limit_update_91001() and layout_paragraphs_limit_update_91002():

[error] Call to a member function getRegions() on null

The patch attached should fix this error.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇩🇪Germany larskleiner

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

Comments & Activities

  • Issue created by @larskleiner
  • 🇭🇺Hungary nagy.balint

    Hi!

    Thanks!

    1)
    If I understand correctly this can happen if a layout was removed while the module's config still had data for it, and so the update can fail in that case.
    Although won't this leave the incorrect config in the module's config intact then?
    As the update hooks change structure, but they don't completely replace the full array without the skipped items.

    2)
    Couldn't we use something like

    if (!($layoutDefinitions[$lid] instanceof LayoutDefinition)) {
            continue;
        }

    So the patch is easier to review, and -> https://www.youtube.com/shorts/Zmx0Ou5TNJs

  • 🇩🇪Germany larskleiner

    1) Both these update hooks are supposed to migrate existing configuration into the new schema after the changes in #3367175, correct?

    I would argue you don't need these update hooks as users would likely want to change config after updating this module since there wasn't an option to define limits by region before. Once they changed and re-exported the updated config manually, any old config would be completely replaced anyway.

    2) Works for me as long as the database updates go through ok :-)

  • 🇦🇹Austria hudri Austria

    I would argue you don't need these update hooks as users would likely want to change config after updating this module since there wasn't an option to define limits by region before.

    Any change in the config structure should always include an update hook that re-creates the old behavior. If that is not possible, it would need a major version bump.

    Posting this here because of #3381902 Configure disallowed paragraphs per content type Active , which would need an update hook that re-applys all limits to all bundles with layout paragraphs enabled.

Production build 0.71.5 2024