From 31bf50d69d7d2e49321e4b3cc7d4a507372d33a2 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Mon, 12 Apr 2010 03:19:11 +0000 Subject: [PATCH] MINOR when a parent page is unpublished, unpublish all related virtual pages, includes test coverage (from r94777) (from r96771) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102399 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/SiteTree.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/model/SiteTree.php b/core/model/SiteTree.php index 6df790923..58f0ec126 100755 --- a/core/model/SiteTree.php +++ b/core/model/SiteTree.php @@ -1997,6 +1997,15 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid $this->write(); + // Unpublish all virtual pages that point here + // This coupling to the subsites module is frustrating, but difficult to avoid. + if(class_exists('Subsite')) { + $virtualPages = Subsite::get_from_all_subsites('VirtualPage', "CopyContentFromID = {$this->ID}"); + } else { + $virtualPages = DataObject::get('VirtualPage', "CopyContentFromID = {$this->ID}"); + } + if ($virtualPages) foreach($virtualPages as $vp) $vp->doUnpublish(); + $this->extend('onAfterUnpublish'); }