BUGFIX Count() call on a non-object in File::BackLinkTrackingCount() (from r109079)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112773 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2010-10-19 00:53:21 +00:00
parent db8035e1a1
commit e6976a8458

View File

@ -169,7 +169,12 @@ class File extends DataObject {
* @return Integer * @return Integer
*/ */
function BackLinkTrackingCount() { 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() { protected function onAfterDelete() {
parent::onAfterDelete(); parent::onAfterDelete();
if($brokenPages = $this->BackLinkTracking()) { $brokenPages = $this->BackLinkTracking();
if($brokenPages) {
$origStage = Versioned::current_stage(); $origStage = Versioned::current_stage();
// This will syncLinkTracking on draft // This will syncLinkTracking on draft