Problem/Motivation

I've been using ctools_block to expose fields as blocks available for placement on /admin/structure/block. When layout_builder is enabled, content fields are no longer available for selection on the "Place block" list - except for paragraphs exposed by paragraph_blocks (enabling or disabling that module has no effect on the problem between ctools_block and layout_builder).

Fields that I had placed as blocks before enabling layout_builder are still available to move or configure; I just can't add any new field blocks.

Drupal 8.7.7
ctools 3.2.0

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

Kasey_MK created an issue. See original summary.

kasey_mk’s picture

Issue summary: View changes
tim.plunkett’s picture

That's the fault of layout_builder_plugin_filter_block__block_ui_alter(), added in #2968139: Layout Builder field blocks show up on Block UI when they shouldn't.

Not sure what to do about it, but that's why it is happening.

tim.plunkett’s picture

Actually, I'm not sure why that's happening. Because the code I referenced has this check:

$definition['provider'] === 'layout_builder'

Which should exclude any CTools-provided blocks...

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.9 was released on November 6 and is the final full bugfix release for the Drupal 8.7.x series. Drupal 8.7.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.8.0 on December 4, 2019. (Drupal 8.8.0-beta1 is available for testing.)

Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

neuquen’s picture

We are seeing this error now too. Is there a patch or fix of any kind for this?

kasey_mk’s picture

Two workarounds (thankfully, once a content field is placed as a block, it doesn't disappear when layout_builder is enabled; you just can't place new ones via the UI):

  • Uninstall layout_builder, place new content fields in blocks, drush cex, throw away any changes not related to new blocks, re-enable layout_builder.
  • Duplicate the config .yml file for an existing content-field block, throw away its UUID values, edit any relevant info, then drush cim to import the block, then drush cex to get a new UUID and adjust the weights of any surrounding blocks.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

tim.plunkett’s picture

Version: 8.9.x-dev » 9.1.x-dev
Issue summary: View changes
Status: Active » Postponed (maintainer needs more info)
Issue tags: +Needs steps to reproduce

Is this still occurring? And only with CTools blocks?

Please write steps to reproduce if so.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

mpotter’s picture

I think I just ran into this. I have a taxonomy entity_reference field on a content type and am not seeing it in the list of content blocks I can add to the default layout. This site was built several months ago so not sure when this field was added, but it likely was added after layout builder was already enabled. This is a D9.0 site.

Going to dig into this a bit to see if I can determine the problem, but under time pressure so also looking for the fastest way to work around it. I cannot just disable layout builder because of existing dependencies.

mpotter’s picture

I noticed that in the config YML file for the entity_view_display for the view mode using layout builder, the missing field (field_topic) was down in the "hidden" section at the bottom. It's the only field in that section and probably left over from before layout builder was enabled for this view mode. Disabling layout builder for this view mode and moving the field into the visible section and then re-enabling layout builder doesn't seem to help. Even editing the YML file manually and importing config doesn't help. Feels like this list of allowed field blocks is cached somewhere else.

If I install the layout_builder_restrictions module, I also do not see this field block in the list of allowed blocks that I can whitelist or blacklist. So still not sure what is different about this field.

mpotter’s picture

Also, I don't think this is a CTools block, I think it is just a field_block as defined for layout_builder.

mpotter’s picture

Apparently this field on this content type used to be called something else. Originally there was a shared field_topic and a specific field_blog_topic (on the Blog content type). There was an update hook to migrate field_blog_topic into field_topic and use that shared field on the Blog instead. That process has somehow prevented the field_topic from being available as a field_block for the Blog content type. It *IS* available as a block on other content types.

Doing a DB dump and grepping the SQL file shows no reference to the old field_blog_topic. So it's not still set in some cache table. However, whatever process was used to put the field_topic into the Blog content type must not have set some other table that field_block is looking at. Going to debug into the field_block listing now to track this down further.

mpotter’s picture

OK, confirmed this is a site-specific issue, not a layout_builder issue (at least in this specific case). Debugging the plugin discovery, when it gets to the `getDerivativeDefinitions` within `FieldBlockDeriver.php` in layout builder, it checks the bundles for each field. For some reason on this site the "blog" bundle is not listed in the field_info array for the field_topic.

Still have no idea how this happened since I can edit/create blogs and use the field_topic just fine and all the rest of the site seems to work fine with this field on blog. I'll need to track down where the field_info is coming from in core.

mpotter’s picture

For any others running into this, my site specific problem was that the `key_value` table has a cached `entity.definitions.bundle_field_map` collection for `node` that contains the list of allowed bundles per field. This is "state" data, so clearing cache doesn't alter it. Somehow when this field was renamed programatically, the key_value table didn't get updated. Saving the field on the node doesn't fix this. I had to write an update hook to manually patch the data in this table. This is probably a core bug somewhere, but I've seen plenty of other abuses of the key_value table being used as a permanent cache like this.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

anybody’s picture

Status: Postponed (maintainer needs more info) » Active

Setting this back to active as I think we found a crazy bug @mpotter. What you described in #16 quite exactly seems to match what also happens in other cases like for example if paragraphs module has been uninstalled!

And the error only appears when layout_builder is enabled. We hadn't had layout_builder in use for example, but tried paragraphs weeks before (then uninstalled paragraps). When activating layout_paragraphs, the

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "paragraph" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition()

was thrown!

Reason were (like you described in #16), orphaned "paragraphs" entries in the key_value table, which layout_builder seems to use in any way...

For details see:
#3165612: The "paragraph" entity type does not exist error after uninstallation due to left key_value entries
#3169812: Entity type does not exist when trying to use Layout Builder

So I guess these might be two separate issues like

  1. "Paragraphs uninstall (and perhaps other entity modules) leave orphaned entity entries in key_value table"
  2. "Layout Builder loads non-existing entity types from key_value"

PLUS what you initially described in this issue (different outcome)

But core maintainers should have a look, I'm not good enough at this topic.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.