mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-08-24 19:45:52 +02:00
BUGFIX: Virtual pages can be deleted from the live site even when the're not publishable. (from r93319)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@96758 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
92b4a32e5e
commit
332ddb700a
@ -65,9 +65,19 @@ class VirtualPage extends Page {
|
|||||||
return $this->isPublishable() && parent::canPublish($member);
|
return $this->isPublishable() && parent::canPublish($member);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if we can delete this page from the live site, which is different from can
|
||||||
|
* we publish it.
|
||||||
|
*/
|
||||||
|
public function canDeleteFromLive($member = null) {
|
||||||
|
return parent::canPublish($member);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if is page is publishable by anyone at all
|
* Returns true if is page is publishable by anyone at all
|
||||||
* Return false if the source page isn't published yet.
|
* Return false if the source page isn't published yet.
|
||||||
|
*
|
||||||
|
* Note that isPublishable doesn't affect ete from live, only publish.
|
||||||
*/
|
*/
|
||||||
public function isPublishable() {
|
public function isPublishable() {
|
||||||
// No source
|
// No source
|
||||||
|
@ -126,4 +126,29 @@ class VirtualPageTest extends SapphireTest {
|
|||||||
$this->assertTrue($vp->canPublish());
|
$this->assertTrue($vp->canPublish());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testCanDeleteOrphanedVirtualPagesFromLive() {
|
||||||
|
// An unpublished source page
|
||||||
|
$p = new Page();
|
||||||
|
$p->Content = "test content";
|
||||||
|
$p->write();
|
||||||
|
$p->doPublish();
|
||||||
|
|
||||||
|
// With no source page, we can't publish
|
||||||
|
$vp = new VirtualPage();
|
||||||
|
$vp->CopyContentFromID = $p->ID;
|
||||||
|
$vp->write();
|
||||||
|
|
||||||
|
// Delete the source page
|
||||||
|
$this->assertTrue($vp->canPublish());
|
||||||
|
$this->assertTrue($p->doDeleteFromLive());
|
||||||
|
|
||||||
|
// Confirm that we can unpublish, but not publish
|
||||||
|
$this->assertTrue($vp->canDeleteFromLive());
|
||||||
|
$this->assertFalse($vp->canPublish());
|
||||||
|
|
||||||
|
// Confirm that the action really works
|
||||||
|
$this->assertTrue($vp->doDeleteFromLive());
|
||||||
|
$this->assertNull(DB::query("SELECT \"ID\" FROM \"SiteTree_Live\" WHERE \"ID\" = $vp->ID")->value());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user