BUGFIX: Fixed SiteTree::IsModifiedOnStage() for an edge-case that was identified when deleteFromStage() stopped manipulating the current record. (from r106082)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112516 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-10-15 02:56:05 +00:00
parent c7b47d8a8b
commit 2aed7be053
2 changed files with 6 additions and 1 deletions

View File

@ -2482,7 +2482,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
$stageVersion = Versioned::get_versionnumber_by_stage('SiteTree', 'Stage', $this->ID); $stageVersion = Versioned::get_versionnumber_by_stage('SiteTree', 'Stage', $this->ID);
$liveVersion = Versioned::get_versionnumber_by_stage('SiteTree', 'Live', $this->ID); $liveVersion = Versioned::get_versionnumber_by_stage('SiteTree', 'Live', $this->ID);
return ($stageVersion != $liveVersion); return ($stageVersion && $stageVersion != $liveVersion);
} }
/** /**

View File

@ -801,6 +801,11 @@ class Versioned extends DataObjectDecorator {
$clone = clone $this->owner; $clone = clone $this->owner;
$result = $clone->delete(); $result = $clone->delete();
Versioned::set_reading_mode($oldMode); Versioned::set_reading_mode($oldMode);
// Fix the version number cache (in case you go delete from stage and then check ExistsOnLive)
$baseClass = ClassInfo::baseDataClass($this->owner->class);
self::$cache_versionnumber[$baseClass][$stage][$this->owner->ID] = null;
return $result; return $result;
} }