Misleading documentation about how block instances are stored

Created on 19 September 2022, about 2 years ago
Updated 6 September 2024, 22 days ago

Problem/Motivation

I needed to replace some block instances via a database update hook, and while I was working on the implementation I took a look to how the actual field values are stored because they must be treated as content meanwhile blocks are configuration entities. So I realized that the block_field field type just stores the block plugin ID along with the block settings in the database and when the block needs to be displayed, it just creates a block instance "on the fly" (with proper caching of course).

So the block instances are actually not stored as configuration entities, they don't even exist unless the field is rendered. What was misleading for me is that the project page and the README.md also states that:

The Block field's block instances are stored as configuration, which is good thing, since site builders and editors can easily tweak them with impacting any configuration management.

And I think this is a bit confusing if someone just quickly reads the documentation without taking a look at the implementation details. Or, perhaps I just misunderstand something and the module works differently. Could someone please clarify this?

πŸ“Œ Task
Status

Needs review

Version

1.0

Component

Documentation

Created by

πŸ‡­πŸ‡ΊHungary balazswmann

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¬πŸ‡§United Kingdom joachim

    I think what it's trying to say is that the block field's blocks have their configuration stored in the entity field, so site builders and editors can easily tweak them WITHOUT impacting any configuration management.

    Agreed it's unclear and doesn't make any sense currently.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    @balazswmann could you perhaps help and prepare a MR for the README.md based on the reply from @joachim? That would surely help a lot. Thanks for raising this point!

  • First commit to issue fork.
  • Merge request !248.x 1.x β†’ (Open) created by NicolasH
  • Pipeline finished with Success
    about 2 months ago
    Total: 147s
    #241949
  • Status changed to Needs review about 2 months ago
  • πŸ‡¦πŸ‡ΊAustralia NicolasH

    I was initially confused by the description as well. It's correct, just that "configuration" is a bit ambiguous in this context. Took a stab at clarifying that it's concerning block configuration/settings.

    This hopefully makes it clear that it's quite lightweight and essentially content on the entity, rather than something that from then on needs to be managed via Drupal config commits.

  • First commit to issue fork.
  • Pipeline finished with Success
    about 2 months ago
    Total: 262s
    #245129
  • πŸ‡ΊπŸ‡ΈUnited States mlncn Minneapolis, MN, USA

    (It was already sentences, of course, i broke up one long sentence into two. I hope my edits are clearer than my commit message!)

    Liked the improvement, tried to take it a little further.

  • πŸ‡¦πŸ‡ΊAustralia NicolasH

    Yep, fine with me. Just noticed there's test failures, but they don't seem to be related to any of these changes. Not sure if it's due to how the MR was set up.

  • Status changed to RTBC about 2 months ago
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    @balazswmann & @joachim all fine with the new text?

    LGTM and tests don't fail anymore, that was clearly unrelated!

  • Status changed to Needs work about 2 months ago
  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    Not sure this is much of an improvement. This introduces concepts that don't really exist like that, there is no such thing as an "original block" and "copy of that blocks configuration".

    What we store is a block *plugin* ID and configuration for it. A block plugin has default configuration, but ours isn't a copy of that, it's just *the* configuration.

    To differentiate it from block.module with the block config entities, what might be useful is to be more specific about that. Something like "This module does not store references to block config entities, which are placed in regions, it instead directly references the underlying block plugin ID's with configuration for them. As a result, each block placement is stored only in the given field as part of that content entity and is not part of Drupal's configuration management system.".

    The storage here is fairly similar to layout_builder, that also stores block plugin ID's with configuration, it just also happens to have layouts as an extra wrapper, while we store only a single block per field item. Maybe comparing it with that will make it easier to understand? Something like a comparison table?

  • Status changed to Needs review 22 days ago
  • πŸ‡¦πŸ‡ΊAustralia NicolasH

    Thanks for clearing that up. Trying to maintain the emphasis on the original request, which is that the current description easily leads to the assumption that this utilises the site configuration system. Don't think this needs to get into layout storage comparison at this point, but might be useful in some more detailed doc?

    Anyway, leaving it for others to refine this further if needed.

  • Pipeline finished with Failed
    22 days ago
    Total: 830s
    #275562
Production build 0.71.5 2024