Skip to content

Commit

Permalink
Prevent Layout status from building a Layout when Layout Publish tran…
Browse files Browse the repository at this point in the history
…saction in active

fixes xibosignage/xibo#2404

(cherry picked from commit 0ece54c)
  • Loading branch information
PeterMis committed Jan 27, 2021
1 parent 06faee9 commit 1e2f5e7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/Controller/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
12 changes: 9 additions & 3 deletions lib/Entity/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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', [
Expand Down Expand Up @@ -2091,7 +2097,7 @@ public function publishDraft()
'saveLayout' => true,
'saveRegions' => false,
'saveTags' => false,
'setBuildRequired' => true,
'setBuildRequired' => false,
'validate' => false,
'audit' => true,
'notify' => false
Expand Down

0 comments on commit 1e2f5e7

Please sign in to comment.