Score:1

How to restore layout builder override layouts from old DB snapshot?

ru flag

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 ?
Score:0
ru flag

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.

Score:0
cn flag

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.