diff --git a/filesystem/File.php b/filesystem/File.php index 26a798d24..6269954bb 100755 --- a/filesystem/File.php +++ b/filesystem/File.php @@ -169,7 +169,12 @@ class File extends DataObject { * @return Integer */ function BackLinkTrackingCount() { - return $this->BackLinkTracking()->Count(); + $pages = $this->BackLinkTracking(); + if($pages) { + return $pages->Count(); + } else { + return 0; + } } /** @@ -194,7 +199,8 @@ class File extends DataObject { protected function onAfterDelete() { parent::onAfterDelete(); - if($brokenPages = $this->BackLinkTracking()) { + $brokenPages = $this->BackLinkTracking(); + if($brokenPages) { $origStage = Versioned::current_stage(); // This will syncLinkTracking on draft