Commit 89bdb05c authored by catch's avatar catch
Browse files

Issue #2897576 by Lendude, Ismaels: Resaving a view display results in deletion of view display

parent 38fd4ceb
......@@ -64,6 +64,12 @@ public function testOtherOptions() {
$this->assertIdentical($displays['test_1']['id'], 'test_1', 'New display ID matches the display ID key.');
$this->assertFalse(array_key_exists('attachment_1', $displays), 'Old display ID not found.');
// Set to the same machine name and save the View.
$edit = ['display_id' => 'test_1'];
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/test_1/display_id', $edit, 'Apply');
$this->drupalPostForm(NULL, [], 'Save');
$this->assertLink(t('test_1'));
// Test the form validation with invalid IDs.
$machine_name_edit_url = 'admin/structure/views/nojs/display/test_view/test_1/display_id';
$error_text = t('Display name must be letters, numbers, or underscores only.');
......
......@@ -275,7 +275,7 @@ public function save(array $form, FormStateInterface $form_state) {
// Rename display ids if needed.
foreach ($executable->displayHandlers as $id => $display) {
if (!empty($display->display['new_id']) && empty($display->display['deleted'])) {
if (!empty($display->display['new_id']) && $display->display['new_id'] !== $display->display['id'] && empty($display->display['deleted'])) {
$new_id = $display->display['new_id'];
$display->display['id'] = $new_id;
unset($display->display['new_id']);
......@@ -290,6 +290,9 @@ public function save(array $form, FormStateInterface $form_state) {
'display_id' => $new_id,
]);
}
elseif (isset($display->display['new_id'])) {
unset($display->display['new_id']);
}
}
$view->set('display', $displays);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment