Problem/Motivation

I ran an update from 8.7 alpha1 to beta1 and encountered the following fatal:

[notice] Update started: layout_builder_post_update_make_layout_untranslatable
Error: Call to a member function isTranslatable() on null in /data/app/core/modules/layout_builder/layout_builder.post_update.php on line 205 #0 /data/vendor/drush/drush/src/Commands/core/UpdateDBCommands.php(260): layout_builder_post_update_make_layout_untranslatable(Array)
...
Error: Call to a member function isTranslatable() on null in layout_builder_post_update_make_layout_untranslatable() (line 205 of /data/app/core/modules/layout_builder/layout_builder.post_update.php).

The field map reflects the layout_builder__layout field existing in a bundle that was introduced and deleted early in the development cycle. The bundle isn't listed for any of the other fields.

Proposed resolution

  • Be more defensive in layout_builder_post_update_make_layout_untranslatable to protect against incorrect field maps.
  • Figure out why the field isn't updated in the field map when a bundle is deleted.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Sam152 created an issue. See original summary.

Sam152’s picture

Status: Active » Needs review
FileSize
1.02 KB

First part of the proposed resolution, to unblock updating.

tim.plunkett’s picture

Figure out why the field isn't updated in the field map when a bundle is deleted.

This would be MUCH more desirable IMO...

Having fixed at least one bug in the field map during LB dev and hitting several more, I'm starting to think it can't be trusted...

Sam152’s picture

Yeah, making sure the field map is accurate when bundles are deleted would be preferable. It might also be worth making the update hook more defensive for sites that are already in that state though.

amateescu’s picture

Version: 8.8.x-dev » 8.7.x-dev
Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs followup

Let's open a followup to investigate why the field map was not properly updated when the bundle was deleted. We should probably start by adding test coverage to EntityBundleListenerTest.

In the meantime, I think this patch is very helpful as a quick fix for the first patch 8.7.x patch release.

tim.plunkett’s picture

See also #2985882: Workaround for "Call to a member function getLabel() after enabling layout_builder" which is about the field map not matching what actually exists

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 2: 3046007-2.patch, failed testing. View results

amateescu’s picture

Status: Needs work » Reviewed & tested by the community
alexpott’s picture

Let's add a comment that explains why.

amateescu’s picture

The comment makes sense to me, thanks @alexpott :)

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

So let's add the defensive code but we definitely should continue to investigate how it gets out-of-sync - hopefully #2985882: Workaround for "Call to a member function getLabel() after enabling layout_builder" can fix this.

Committed and pushed 13cbe41170 to 8.8.x and 798d3cccbc to 8.7.x. Thanks!

  • alexpott committed 13cbe41 on 8.8.x
    Issue #3046007 by Sam152, alexpott, amateescu, tim.plunkett: In some...

  • alexpott committed 798d3cc on 8.7.x
    Issue #3046007 by Sam152, alexpott, amateescu, tim.plunkett: In some...
Sam152’s picture

Out of interest, is there is a reason the field map isn't regenerated on cache rebuild?

Status: Fixed » Closed (fixed)

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