From c9f5ca6c722843ae563bfe2b23904737f218d8d0 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Wed, 29 Nov 2017 14:23:28 +1300 Subject: [PATCH] FIX Handle thrown exceptions because of obsolete class names --- src/Tasks/CheckExternalLinksTask.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Tasks/CheckExternalLinksTask.php b/src/Tasks/CheckExternalLinksTask.php index d83d5fe..c5d8204 100644 --- a/src/Tasks/CheckExternalLinksTask.php +++ b/src/Tasks/CheckExternalLinksTask.php @@ -14,6 +14,7 @@ use SilverStripe\ExternalLinks\Tasks\LinkChecker; use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DB; +use SilverStripe\ORM\ValidationException; class CheckExternalLinksTask extends BuildTask { @@ -194,7 +195,12 @@ public function runLinksCheck($limit = null) // Update content of page based on link fixes / breakages $htmlValue->saveHTML(); $page->Content = $htmlValue->getContent(); - $page->write(); + try { + $page->write(); + } catch (ValidationException $ex) { + $this->log("Exception caught for {$page->Title}, skipping. Message: " . $ex->getMessage()); + continue; + } // Once all links have been created for this page update HasBrokenLinks $count = $pageTrack->BrokenLinks()->count();