BUGFIX Checking for "$this instanceof VirtualPage" instead of "$this->class == 'VirtualPage' to support subclassing in VirtualPage->onBeforeWrite()

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@67150 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-12-02 04:07:51 +00:00 committed by Sam Minnee
parent 9c87ec7220
commit 4469283166

View File

@ -99,10 +99,13 @@ class VirtualPage extends Page {
function onBeforeWrite() {
// Don't do this stuff when we're publishing
if(!$this->extension_instances['Versioned']->migratingVersion) {
if(isset($this->changed['CopyContentFromID']) && $this->changed['CopyContentFromID']
&& $this->CopyContentFromID != 0 && $this->class == 'VirtualPage' ) {
$CopyContentFromID = $this->CopyContentFromID;
$source = DataObject::get_one("SiteTree","`SiteTree`.`ID`='$CopyContentFromID'");
if(
isset($this->changed['CopyContentFromID'])
&& $this->changed['CopyContentFromID']
&& $this->CopyContentFromID != 0
&& $this instanceof VirtualPage
) {;
$source = DataObject::get_one("SiteTree","`SiteTree`.`ID`='$this->CopyContentFromID'");
$this->copyFrom($source);
$this->URLSegment = $source->URLSegment . '-' . $this->ID;
}