From 1e2f5e70737cb761761a512f49045733f0a58063 Mon Sep 17 00:00:00 2001 From: Peter Date: Wed, 27 Jan 2021 13:16:41 +0000 Subject: [PATCH] Prevent Layout status from building a Layout when Layout Publish transaction in active fixes xibosignage/xibo#2404 (cherry picked from commit 0ece54cee26afb7bc0afc1263c97f218f1998c6e) --- lib/Controller/Layout.php | 2 +- lib/Entity/Layout.php | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/Controller/Layout.php b/lib/Controller/Layout.php index 0269fd9b5d..3464d0a852 100644 --- a/lib/Controller/Layout.php +++ b/lib/Controller/Layout.php @@ -2583,7 +2583,7 @@ public function publish(Request $request, Response $response, $id) // We also build the XLF at this point, and if we have a problem we prevent publishing and raise as an // error message - $draft->xlfToDisk(['notify' => true, 'exceptionOnError' => true, 'exceptionOnEmptyRegion' => false]); + $draft->xlfToDisk(['notify' => true, 'exceptionOnError' => true, 'exceptionOnEmptyRegion' => false, 'publishing' => true]); // Return $this->getState()->hydrate([ diff --git a/lib/Entity/Layout.php b/lib/Entity/Layout.php index 4003f040cf..fddcc78c31 100644 --- a/lib/Entity/Layout.php +++ b/lib/Entity/Layout.php @@ -1896,12 +1896,13 @@ public function xlfToDisk($options = []) 'notify' => true, 'collectNow' => true, 'exceptionOnError' => false, - 'exceptionOnEmptyRegion' => true + 'exceptionOnEmptyRegion' => true, + 'publishing' => false ], $options); $path = $this->getCachePath(); - if ($this->status == 3 || !file_exists($path)) { + if ($this->status == 3 || !file_exists($path) || ($options['publishing'] && $this->status == 5) ) { $this->getLog()->debug('XLF needs building for Layout ' . $this->layoutId); @@ -2012,6 +2013,11 @@ public function publishDraft() // Get my parent for later $parent = $this->layoutFactory->loadById($this->parentId); + $this->getStore()->isolated('UPDATE `layout` SET status = 5 WHERE layoutId = :layoutId', [ + 'layoutId' => $this->layoutId + ]); + $this->getStore()->commitIfNecessary('isolated'); + // I am the draft, so I clear my parentId, and set the parentId of my parent, to myself (swapping us) // Make me the parent. $this->getStore()->update('UPDATE `layout` SET parentId = NULL WHERE layoutId = :layoutId', [ @@ -2091,7 +2097,7 @@ public function publishDraft() 'saveLayout' => true, 'saveRegions' => false, 'saveTags' => false, - 'setBuildRequired' => true, + 'setBuildRequired' => false, 'validate' => false, 'audit' => true, 'notify' => false