mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
FIX: Setting hide_ancestor=true causes a random page type to be hidden
This commit is contained in:
parent
6513f8ac49
commit
fb43e59b00
@ -392,7 +392,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static public function page_type_classes() {
|
||||
public static function page_type_classes() {
|
||||
$classes = ClassInfo::getValidSubClasses();
|
||||
|
||||
$baseClassIndex = array_search('SiteTree', $classes);
|
||||
@ -417,8 +417,10 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
$kill_ancestors = array_unique($kill_ancestors);
|
||||
foreach($kill_ancestors as $mark) {
|
||||
// unset from $classes
|
||||
$idx = array_search($mark, $classes);
|
||||
unset($classes[$idx]);
|
||||
$idx = array_search($mark, $classes, true);
|
||||
if ($idx !== false) {
|
||||
unset($classes[$idx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -871,6 +871,15 @@ class SiteTreeTest extends SapphireTest {
|
||||
$classes = SiteTree::page_type_classes();
|
||||
$this->assertNotContains('SiteTree', $classes, 'Page types do not include base class');
|
||||
$this->assertContains('Page', $classes, 'Page types do contain subclasses');
|
||||
|
||||
// Testing what happens in an incorrect config value is set - hide_ancestor should be a string
|
||||
Config::inst()->update('SiteTreeTest_ClassA', 'hide_ancestor', true);
|
||||
$newClasses = SiteTree::page_type_classes();
|
||||
$this->assertEquals(
|
||||
$classes,
|
||||
$newClasses,
|
||||
'Setting hide_ancestor to a boolean (incorrect) value caused a page class to be hidden'
|
||||
);
|
||||
}
|
||||
|
||||
public function testAllowedChildren() {
|
||||
|
Loading…
Reference in New Issue
Block a user