Skip to content

Commit

Permalink
Merge pull request #701 from yalesites-org/YSP-551-reusable-block-error
Browse files Browse the repository at this point in the history
YSP-551: Toggling a block as reusable on a page leads to white screen error page
  • Loading branch information
dblanken-yale authored Jul 31, 2024
2 parents 6ce7f1b + 103e3e3 commit a3211cf
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
From f046b109bdaa308f3063980026c0b63227469012 Mon Sep 17 00:00:00 2001
From: David Blankenship <[email protected]>
Date: Mon, 29 Jul 2024 11:15:16 -0400
Subject: [PATCH] apply saved

---
.../layout_builder/src/Form/ConfigureBlockFormBase.php | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/core/modules/layout_builder/src/Form/ConfigureBlockFormBase.php b/core/modules/layout_builder/src/Form/ConfigureBlockFormBase.php
index 8dd6333269..16b0a8cd70 100644
--- a/core/modules/layout_builder/src/Form/ConfigureBlockFormBase.php
+++ b/core/modules/layout_builder/src/Form/ConfigureBlockFormBase.php
@@ -365,7 +365,15 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$block_content = $form['settings']['block_form']['#block'];
$block_content->setReusable();
$block_content->setInfo($block_info);
- $block_content->save();
+ $saved = $block_content->save();
+
+ // If it didn't save, it's probably because we're using the same cloned
+ // item somewhere else with different revisions. So, we'll create a new
+ // block_content item to make sure it's fresh and won't interfere.
+ if (!$saved) {
+ $block_content = $block_content->createDuplicate();
+ $block_content->save();
+ }

$block_label_display = $form_state->getValue('settings')['label_display'];
$this->block = $this->blockManager->createInstance('block_content:' . $block_content->uuid(), [
--
2.45.2

1 change: 1 addition & 0 deletions web/profiles/custom/yalesites_profile/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
"drupal/core": {
"plural results summary https://www.drupal.org/project/drupal/issues/2888320": "https://www.drupal.org/files/issues/2021-12-15/2888320-78.patch",
"Add reusable option to inline block creation https://www.drupal.org/project/drupal/issues/2999491": "https://git.drupalcode.org/issue/drupal-2999491/-/commit/1330eff91b1234979cf697a66a48e34eb116b441.patch",
"Update \"Add reusable option to inline block creation\" patch with local changes to save block if it didn't save": "patches/layout_builder/1330eff91b1234979cf697a66a48e34eb116b441-1.patch",
"Prevent empty block_content info fields from causing php deprecation notices": "https://www.drupal.org/files/issues/2023-07-21/3340159-empty-block-label_0.patch"
},
"drupal/entity_redirect": {
Expand Down

0 comments on commit a3211cf

Please sign in to comment.