From 94d354de4a2eea8af1c7833935f419dcfbfd7fa3 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 28 Apr 2015 23:34:26 +1200 Subject: [PATCH] Fixed BacklinkTracking filter usage Previous deprecation fixes made this method error out when called on the root node (ID=0), so when admin/assets is first called. --- code/model/SiteTreeFileExtension.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/code/model/SiteTreeFileExtension.php b/code/model/SiteTreeFileExtension.php index 0ec1ad0b..37cccd6c 100644 --- a/code/model/SiteTreeFileExtension.php +++ b/code/model/SiteTreeFileExtension.php @@ -72,10 +72,13 @@ class SiteTreeFileExtension extends DataExtension { Please manipluate the returned list directly.', Deprecation::SCOPE_GLOBAL); } - $links = $this->owner->getManyManyComponents('BackLinkTracking') - ->where($filter) - ->sort($sort) - ->limit($limit); + $links = $this->owner->getManyManyComponents('BackLinkTracking'); + if($this->owner->ID) { + $links = $links + ->where($filter) + ->sort($sort) + ->limit($limit); + } $this->owner->extend('updateBackLinkTracking', $links); if(class_exists("Subsite")){