From a52cb9209b70d6afd34c33ca9784f0602e0c29c8 Mon Sep 17 00:00:00 2001 From: Dylan Wagstaff Date: Mon, 27 Nov 2017 15:30:34 +1300 Subject: [PATCH] Update UPDATE query to use true table name, not assumed one --- src/Tasks/CheckExternalLinksTask.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Tasks/CheckExternalLinksTask.php b/src/Tasks/CheckExternalLinksTask.php index 41078a8..84a8551 100644 --- a/src/Tasks/CheckExternalLinksTask.php +++ b/src/Tasks/CheckExternalLinksTask.php @@ -7,11 +7,13 @@ use SilverStripe\ExternalLinks\Model\BrokenExternalPageTrack; use SilverStripe\ExternalLinks\Model\BrokenExternalPageTrackStatus; use SilverStripe\Dev\BuildTask; use SilverStripe\Core\Config\Config; +use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DB; use SilverStripe\Dev\Debug; use DOMNode; use SilverStripe\Core\Injector\Injector; use SilverStripe\ExternalLinks\Tasks\LinkChecker; +use SilverStripe\CMS\Model\SiteTree; class CheckExternalLinksTask extends BuildTask { @@ -188,9 +190,11 @@ class CheckExternalLinksTask extends BuildTask $count = $pageTrack->BrokenLinks()->count(); $this->log("Found {$count} broken links"); if ($count) { + $siteTreeTable = DataObject::getSchema()->tableName(SiteTree::class); // Bypass the ORM as syncLinkTracking does not allow you to update HasBrokenLink to true DB::query(sprintf( - 'UPDATE "SiteTree" SET "HasBrokenLink" = 1 WHERE "ID" = \'%d\'', + 'UPDATE "%s" SET "HasBrokenLink" = 1 WHERE "ID" = \'%d\'', + $siteTreeTable, intval($pageTrack->ID) )); }