diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index d3d7a04..67d1080 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1815,11 +1815,6 @@ function install_finished(&$install_state) { // Will also trigger indexing of profile-supplied content or feeds. \Drupal::service('cron')->run(); - // Save a snapshot of the initially installed configuration. - $active = \Drupal::service('config.storage'); - $snapshot = \Drupal::service('config.storage.snapshot'); - \Drupal::service('config.manager')->createSnapshot($active, $snapshot); - if ($install_state['interactive']) { // Load current user and perform final login tasks. // This has to be done after drupal_flush_all_caches() diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php index aba35e2..2ba703a 100644 --- a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php +++ b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php @@ -155,8 +155,8 @@ public function id() { * {@inheritdoc} */ public function preSave(EntityStorageInterface $storage, $update = TRUE) { - // Sort elements by weight before saving. - uasort($this->content, 'Drupal\Component\Utility\SortArray::sortByWeightElement'); + ksort($this->content); + ksort($this->hidden); parent::preSave($storage, $update); } diff --git a/core/modules/config/src/Form/ConfigSync.php b/core/modules/config/src/Form/ConfigSync.php index 2742e93..b97218b 100644 --- a/core/modules/config/src/Form/ConfigSync.php +++ b/core/modules/config/src/Form/ConfigSync.php @@ -166,33 +166,34 @@ public function getFormId() { * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { - $snapshot_comparer = new StorageComparer($this->activeStorage, $this->snapshotStorage, $this->configManager); - if (!$form_state->getUserInput() && $snapshot_comparer->createChangelist()->hasChanges()) { - $change_list = array(); - foreach ($snapshot_comparer->getAllCollectionNames() as $collection) { - foreach ($snapshot_comparer->getChangelist(NULL, $collection) as $config_names) { - if (empty($config_names)) { - continue; - } - foreach ($config_names as $config_name) { - $change_list[] = $config_name; + if ($this->snapshotStorage->exists('core.extension')) { + $snapshot_comparer = new StorageComparer($this->activeStorage, $this->snapshotStorage, $this->configManager); + if (!$form_state->getUserInput() && $snapshot_comparer->createChangelist()->hasChanges()) { + $change_list = array(); + foreach ($snapshot_comparer->getAllCollectionNames() as $collection) { + foreach ($snapshot_comparer->getChangelist(NULL, $collection) as $config_names) { + if (empty($config_names)) { + continue; + } + foreach ($config_names as $config_name) { + $change_list[] = $config_name; + } } } + sort($change_list); + $change_list_render = array( + '#theme' => 'item_list', + '#items' => $change_list, + ); + $change_list_html = drupal_render($change_list_render); + drupal_set_message($this->t('Your current configuration has changed. Changes to these configuration items will be lost on the next synchronization: !changes', array('!changes' => $change_list_html)), 'warning'); } - sort($change_list); - $change_list_render = array( - '#theme' => 'item_list', - '#items' => $change_list, - ); - $change_list_html = drupal_render($change_list_render); - drupal_set_message($this->t('Your current configuration has changed. Changes to these configuration items will be lost on the next synchronization: !changes', array('!changes' => $change_list_html)), 'warning'); } $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array( '#type' => 'submit', '#value' => $this->t('Import all'), ); - $source_list = $this->stagingStorage->listAll(); $storage_comparer = new StorageComparer($this->stagingStorage, $this->activeStorage, $this->configManager); if (empty($source_list) || !$storage_comparer->createChangelist()->hasChanges()) { diff --git a/core/modules/config/src/Tests/ConfigExportImportUITest.php b/core/modules/config/src/Tests/ConfigExportImportUITest.php index a172649..da53133 100644 --- a/core/modules/config/src/Tests/ConfigExportImportUITest.php +++ b/core/modules/config/src/Tests/ConfigExportImportUITest.php @@ -90,6 +90,11 @@ protected function setUp() { * Tests a simple site export import case. */ public function testExportImport() { + // After installation there is no snapshot and nothing to import. + $this->drupalGet('admin/config/development/configuration'); + $this->assertNoText(t('Warning message')); + $this->assertText(t('There are no configuration changes to import.')); + $this->originalSlogan = $this->config('system.site')->get('slogan'); $this->newSlogan = $this->randomString(16); $this->assertNotEqual($this->newSlogan, $this->originalSlogan); @@ -113,6 +118,8 @@ public function testExportImport() { 'field_storage' => $this->fieldStorage, 'bundle' => $this->contentType->id(), ))->save(); + // Update the displays so that configuration does not change unexpectedly on + // import. entity_get_form_display('node', $this->contentType->id(), 'default') ->setComponent($this->fieldName, array( 'type' => 'text_textfield', @@ -121,6 +128,12 @@ public function testExportImport() { entity_get_display('node', $this->contentType->id(), 'full') ->setComponent($this->fieldName) ->save(); + entity_get_display('node', $this->contentType->id(), 'default') + ->setComponent($this->fieldName) + ->save(); + entity_get_display('node', $this->contentType->id(), 'teaser') + ->removeComponent($this->fieldName) + ->save(); $this->drupalGet('node/add/' . $this->contentType->id()); $this->assertFieldByName("{$this->fieldName}[0][value]", '', 'Widget is displayed'); @@ -154,7 +167,15 @@ public function testExportImport() { $filename = 'temporary://' . $this->randomMachineName(); file_put_contents($filename, $this->tarball); $this->drupalPostForm('admin/config/development/configuration/full/import', array('files[import_tarball]' => $filename), 'Upload'); + // There is no snapshot yet because an import has never run. + $this->assertNoText(t('Warning message')); + $this->assertNoText(t('There are no configuration changes to import.')); + $this->assertText($this->contentType->label()); + $this->drupalPostForm(NULL, array(), 'Import all'); + // After importing the snapshot has been updated an there are no warnings. + $this->assertNoText(t('Warning message')); + $this->assertText(t('There are no configuration changes to import.')); $this->assertEqual($this->config('system.site')->get('slogan'), $this->newSlogan); @@ -165,7 +186,15 @@ public function testExportImport() { ->set('slogan', $this->originalSlogan) ->save(); $this->drupalGet('admin/config/development/configuration'); + $this->assertText(t('Warning message')); $this->assertText('Your current configuration has changed. Changes to these configuration items will be lost on the next synchronization: system.site'); + // Remove everything from staging. The warning about differences between the + // active and snapshot should still exist. + \Drupal::service('config.storage.staging')->deleteAll(); + $this->drupalGet('admin/config/development/configuration'); + $this->assertText(t('Warning message')); + $this->assertText('Your current configuration has changed. Changes to these configuration items will be lost on the next synchronization: system.site'); + $this->assertText(t('There are no configuration changes to import.')); } /** diff --git a/core/modules/field_ui/src/Tests/EntityDisplayTest.php b/core/modules/field_ui/src/Tests/EntityDisplayTest.php index 5bdc3e6..de5523b 100644 --- a/core/modules/field_ui/src/Tests/EntityDisplayTest.php +++ b/core/modules/field_ui/src/Tests/EntityDisplayTest.php @@ -100,6 +100,25 @@ public function testEntityDisplayCRUD() { } /** + * Test sorting of components by name on basic CRUD operations + */ + public function testEntityDisplayCRUDSort() { + $display = entity_create('entity_view_display', array( + 'targetEntityType' => 'entity_test', + 'bundle' => 'entity_test', + 'mode' => 'default', + )); + $display->setComponent('component_3'); + $display->setComponent('component_1'); + $display->setComponent('component_2'); + $display->removeComponent('name'); + $display->save(); + $components = array_keys($display->getComponents()); + $expected = array ( 0 => 'component_1', 1 => 'component_2', 2 => 'component_3',); + $this->assertIdentical($components, $expected); + } + + /** * Tests entity_get_display(). */ public function testEntityGetDisplay() {