From 26244b743d2c99001f6d9a22e5d54b197c885b0a Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Tue, 12 Jan 2010 23:22:20 +0000 Subject: [PATCH] BUGFIX: Make virtual page broken link detection work across subsites. (from r91311) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@96740 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/SiteTree.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/model/SiteTree.php b/core/model/SiteTree.php index 0513490e8..7aea13be2 100755 --- a/core/model/SiteTree.php +++ b/core/model/SiteTree.php @@ -1365,7 +1365,14 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid // Also write all VPs pointing here $suffix = Versioned::current_stage() == 'Live' ? '_Live' : ''; - $virtualPages = DataObject::get('VirtualPage', "SiteTree$suffix.ID = SiteTree$suffix.ID AND CopyContentFromID = {$this->ID}"); + + // This coupling to the subsites module is frustrating, but difficult to avoid. + if(class_exists('Subsite')) { + $virtualPages = Subsite::get_from_all_subsites('VirtualPage', "SiteTree$suffix.ID = SiteTree$suffix.ID AND CopyContentFromID = {$this->ID}"); + } else { + $virtualPages = DataObject::get('VirtualPage', "SiteTree$suffix.ID = SiteTree$suffix.ID AND CopyContentFromID = {$this->ID}"); + } + if($virtualPages) foreach($virtualPages as $page) { // $page->write() calls syncLinkTracking, which does all the hard work for us. $page->write();