Skip to content

Commit

Permalink
FIX Ensuring write operations when clearing content is captured in a …
Browse files Browse the repository at this point in the history
…try...catch
  • Loading branch information
ScopeyNZ committed Apr 29, 2019
1 parent 3a9ac5e commit 3f19c0a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Tasks/MigrateContentToElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use DNADesign\Elemental\Models\BaseElement;
use DNADesign\Elemental\Models\ElementalArea;
use DNADesign\Elemental\Models\ElementContent;
use Exception;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\BuildTask;
Expand Down Expand Up @@ -86,7 +87,15 @@ public function run($request)
// Write the page if we're clearing content or if the area doesn't exist - we write to trigger a
// relationship update
if ($clearContent || !$area->exists()) {
$page->write();
try {
$page->write();
} catch (Exception $e) {
echo sprintf(
'Could not clear content on page %s: %s',
$page->ID,
$e->getMessage()
);
}

if (!$area->exists()) {
$area = $this->getAreaRelationFromPage($page);
Expand Down

0 comments on commit 3f19c0a

Please # to comment.