mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUGFIX: Fixed operation of the onlyDeletedFromStage parameter of Hierarchy::liveChildren().
This commit is contained in:
parent
5a3242cab7
commit
d1a39b0b1a
@ -562,9 +562,9 @@ class Hierarchy extends DataExtension {
|
|||||||
$children->dataQuery()->setQueryParam('Versioned.stage', 'Live');
|
$children->dataQuery()->setQueryParam('Versioned.stage', 'Live');
|
||||||
|
|
||||||
if($onlyDeletedFromStage) {
|
if($onlyDeletedFromStage) {
|
||||||
// Note that this makes a second query, and could be optimised to be a joi;
|
// Note that this makes a second query, and could be optimised to be a join
|
||||||
$stageChildren = DataObject::get($baseClass)
|
$stageChildren = DataObject::get($baseClass)
|
||||||
->where("\"{$baseClass}\".\"ParentID\" = $id AND \"{$baseClass}\".\"ID\" != $id");
|
->where("\"{$baseClass}\".\"ID\" != $id");
|
||||||
$stageChildren->dataQuery()->setQueryParam('Versioned.mode', 'stage');
|
$stageChildren->dataQuery()->setQueryParam('Versioned.mode', 'stage');
|
||||||
$stageChildren->dataQuery()->setQueryParam('Versioned.stage', '');
|
$stageChildren->dataQuery()->setQueryParam('Versioned.stage', '');
|
||||||
|
|
||||||
|
@ -119,6 +119,37 @@ class HierarchyTest extends SapphireTest {
|
|||||||
$this->assertEquals(2, count($obj2aIdList));
|
$this->assertEquals(2, count($obj2aIdList));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The "only deleted from stage" argument to liveChildren() should exclude
|
||||||
|
* any page that has been moved to another location on the stage site
|
||||||
|
*/
|
||||||
|
function testLiveChildrenOnlyDeletedFromStage() {
|
||||||
|
$obj1 = $this->objFromFixture('HierarchyTest_Object', 'obj1');
|
||||||
|
$obj2 = $this->objFromFixture('HierarchyTest_Object', 'obj2');
|
||||||
|
$obj2a = $this->objFromFixture('HierarchyTest_Object', 'obj2a');
|
||||||
|
$obj2b = $this->objFromFixture('HierarchyTest_Object', 'obj2b');
|
||||||
|
|
||||||
|
// Get a published set of objects for our fixture
|
||||||
|
$obj1->publish("Stage", "Live");
|
||||||
|
$obj2->publish("Stage", "Live");
|
||||||
|
$obj2a->publish("Stage", "Live");
|
||||||
|
$obj2b->publish("Stage", "Live");
|
||||||
|
|
||||||
|
// Then delete 2a from stage and move 2b to a sub-node of 1.
|
||||||
|
$obj2a->delete();
|
||||||
|
$obj2b->ParentID = $obj1->ID;
|
||||||
|
$obj2b->write();
|
||||||
|
|
||||||
|
// Get live children, excluding pages that have been moved on the stage site
|
||||||
|
$children = $obj2->liveChildren(true, true)->column("Title");
|
||||||
|
|
||||||
|
// 2a has been deleted from stage and should be shown
|
||||||
|
$this->assertContains("Obj 2a", $children);
|
||||||
|
|
||||||
|
// 2b has merely been moved to a different parent and so shouldn't be shown
|
||||||
|
$this->assertNotContains("Obj 2b", $children);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class HierarchyTest_Object extends DataObject implements TestOnly {
|
class HierarchyTest_Object extends DataObject implements TestOnly {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user