summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2018-02-19 12:13:43 (GMT)
committerNathaniel Catchpole2018-02-19 12:13:43 (GMT)
commit3d6a12a9bcb3b590c8740d5e504be793c7486c5d (patch)
tree9d88aa36e2301d9d413f1cf339ae4f2d9bd01f4a
parent7eaf9abc729ea837ec20e20380553955adf9afc4 (diff)
Issue #2915175 by vaplas, Phonoman, Lendude: Duplicating a Page to Block after changing the display id and then saving the view destroys the Page
-rw-r--r--core/modules/views/src/Entity/View.php1
-rw-r--r--core/modules/views_ui/tests/src/Functional/DisplayCRUDTest.php10
2 files changed, 11 insertions, 0 deletions
diff --git a/core/modules/views/src/Entity/View.php b/core/modules/views/src/Entity/View.php
index 4e1595e..44007eb 100644
--- a/core/modules/views/src/Entity/View.php
+++ b/core/modules/views/src/Entity/View.php
@@ -245,6 +245,7 @@ class View extends ConfigEntityBase implements ViewEntityInterface {
$display_duplicate = $displays[$old_display_id];
unset($display_duplicate['display_title']);
unset($display_duplicate['display_plugin']);
+ unset($display_duplicate['new_id']);
$displays[$new_display_id] = NestedArray::mergeDeep($displays[$new_display_id], $display_duplicate);
$displays[$new_display_id]['id'] = $new_display_id;
diff --git a/core/modules/views_ui/tests/src/Functional/DisplayCRUDTest.php b/core/modules/views_ui/tests/src/Functional/DisplayCRUDTest.php
index 1e53c71..c1c7cef 100644
--- a/core/modules/views_ui/tests/src/Functional/DisplayCRUDTest.php
+++ b/core/modules/views_ui/tests/src/Functional/DisplayCRUDTest.php
@@ -143,6 +143,16 @@ class DisplayCRUDTest extends UITestBase {
$this->assertFalse(isset($block_1->display['display_options']['path']));
$this->assertEqual($block_1->getOption('title'), $random_title, 'The overridden title option from the display got copied into the duplicate');
$this->assertEqual($block_1->getOption('css_class'), $random_css, 'The overridden css_class option from the display got copied into the duplicate');
+
+ // Test duplicating a display after changing the machine name.
+ $view_id = $view->id();
+ $this->drupalPostForm("admin/structure/views/nojs/display/$view_id/page_2/display_id", ['display_id' => 'page_new'], 'Apply');
+ $this->drupalPostForm(NULL, [], 'Duplicate as Block');
+ $this->drupalPostForm(NULL, [], t('Save'));
+ $view = Views::getView($view_id);
+ $view->initDisplay();
+ $this->assertNotNull($view->displayHandlers->get('page_new'), 'The original display is saved with a changed id');
+ $this->assertNotNull($view->displayHandlers->get('block_2'), 'The duplicate display is saved with new id');
}
}