After upgrading from Drupal v9.1.7 to v9.2.0, on a lot of nodes the custom layout builder override layouts were reset to the default layout, resulting in a massive data loss. To make things worse, this only happened on live and not on stage, and was only noticed a few days later. I don't know what has caused the issue, the customer is pretty upset, and I quickly and selectively need to restore the override layouts from a DB snapshot the night before the update (and leave the rest of the data untouched).

So far I know two things:

  • All affected nodes have a node.changed timestamp matching the time of the update deployment.
  • On all affected nodes node__layout_builder_layout has been trimmed to one section (same as the default, non-override layout)
  • On all affected nodes only the last revision is lost, without generating a new revision id.
  • The override layouts usually consist of custom, non-reuseable block_content blocks. All the blocks still seem to exist in the DB.

I'd like to know:

  1. How can I check if a node has an override layout, or is using the default layout of the layout builder (if possible with a plain SQL query, without PHP)
  2. What else do I need to restore except the node__layout_builder_layout table (assuming custom content blocks used by the override layouts still seem to exist) to restore a node's override layout
  3. Can I savely use SQL where a <> b or SQL where a = b with a and b being the blob content of node__layout_builder_layout.layout_builder__layout_section ?

I can quickly answer the first question. There is a table called node__layout_builder__layout that holds just the nodes that have overridden the default layout for that node. So if you create 2 nodes with IDs 1 and 2 and you use default layout for node 1 but override layout for node 2, in node__layout_builder__layout you will see only the node 2. So you can get all nodes and discriminate the ones found in that table. Be sure you check the delta field to review the differences between revisions.


Answering my question 2:

(IF the referenced custom content blocks, etc. still exist in the DB...)
Restoring the node__layout_builder__layout table does restore the override layouts, no other tables required.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.