mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
BUGFIX: Fix virtual page logic for subsite virtual pages too. (from r93916)
This commit is contained in:
parent
29dda5abdf
commit
4d90cfeeb3
@ -139,7 +139,7 @@ class SiteTreeSubsites extends SiteTreeDecorator {
|
|||||||
$linkedPages = DataObject::get("SubsitesVirtualPage", "CopyContentFromID = {$this->owner->ID}");
|
$linkedPages = DataObject::get("SubsitesVirtualPage", "CopyContentFromID = {$this->owner->ID}");
|
||||||
if($linkedPages) foreach($linkedPages as $page) {
|
if($linkedPages) foreach($linkedPages as $page) {
|
||||||
$page->copyFrom($page->CopyContentFrom());
|
$page->copyFrom($page->CopyContentFrom());
|
||||||
$page->doPublish();
|
if($page->ExistsOnLive) $page->doPublish();
|
||||||
}
|
}
|
||||||
|
|
||||||
Subsite::$disable_subsite_filter = $oldState;
|
Subsite::$disable_subsite_filter = $oldState;
|
||||||
|
@ -62,7 +62,66 @@ class SubsitesVirtualPageTest extends SapphireTest {
|
|||||||
foreach($testFiles as $file) {
|
foreach($testFiles as $file) {
|
||||||
if(file_exists(Director::baseFolder().$file)) unlink(Director::baseFolder().$file);
|
if(file_exists(Director::baseFolder().$file)) unlink(Director::baseFolder().$file);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function testSubsiteVirtualPagesArentInappropriatelyPublished() {
|
||||||
|
// Fixture
|
||||||
|
$p = new Page();
|
||||||
|
$p->Content = "test content";
|
||||||
|
$p->write();
|
||||||
|
$vp = new SubsitesVirtualPage();
|
||||||
|
$vp->CopyContentFromID = $p->ID;
|
||||||
|
$vp->write();
|
||||||
|
|
||||||
|
// VP is oragne
|
||||||
|
$this->assertTrue($vp->IsAddedToStage);
|
||||||
|
|
||||||
|
// VP is still orange after we publish
|
||||||
|
$p->doPublish();
|
||||||
|
$this->fixVersionNumberCache($vp);
|
||||||
|
$this->assertTrue($vp->IsAddedToStage);
|
||||||
|
|
||||||
|
// A new VP created after P's initial construction
|
||||||
|
$vp2 = new SubsitesVirtualPage();
|
||||||
|
$vp2->CopyContentFromID = $p->ID;
|
||||||
|
$vp2->write();
|
||||||
|
$this->assertTrue($vp2->IsAddedToStage);
|
||||||
|
|
||||||
|
// Also remains orange after a republish
|
||||||
|
$p->Content = "new content";
|
||||||
|
$p->write();
|
||||||
|
$p->doPublish();
|
||||||
|
$this->fixVersionNumberCache($vp2);
|
||||||
|
$this->assertTrue($vp2->IsAddedToStage);
|
||||||
|
|
||||||
|
// VP is now published
|
||||||
|
$vp->doPublish();
|
||||||
|
|
||||||
|
$this->fixVersionNumberCache($vp);
|
||||||
|
$this->assertTrue($vp->ExistsOnLive);
|
||||||
|
$this->assertFalse($vp->IsModifiedOnStage);
|
||||||
|
|
||||||
|
// P edited, VP and P both go green
|
||||||
|
$p->Content = "third content";
|
||||||
|
$p->write();
|
||||||
|
|
||||||
|
$this->fixVersionNumberCache($vp, $p);
|
||||||
|
$this->assertTrue($p->IsModifiedOnStage);
|
||||||
|
$this->assertTrue($vp->IsModifiedOnStage);
|
||||||
|
|
||||||
|
// Publish, VP goes black
|
||||||
|
$p->doPublish();
|
||||||
|
$this->fixVersionNumberCache($vp);
|
||||||
|
$this->assertTrue($vp->ExistsOnLive);
|
||||||
|
$this->assertFalse($vp->IsModifiedOnStage);
|
||||||
|
}
|
||||||
|
|
||||||
|
function fixVersionNumberCache($page) {
|
||||||
|
$pages = func_get_args();
|
||||||
|
foreach($pages as $p) {
|
||||||
|
Versioned::prepopulate_versionnumber_cache('SiteTree', 'Stage', array($p->ID));
|
||||||
|
Versioned::prepopulate_versionnumber_cache('SiteTree', 'Live', array($p->ID));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user