diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 95adc95..92e657f 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -3166,7 +3166,7 @@ function _registry_check_code($type, $name = NULL) { $cache_key = $type[0] . $name; if (isset($lookup_cache[$cache_key])) { if ($lookup_cache[$cache_key]) { - require_once DRUPAL_ROOT . '/' . $lookup_cache[$cache_key]; + include_once DRUPAL_ROOT . '/' . $lookup_cache[$cache_key]; } return (bool) $lookup_cache[$cache_key]; } @@ -3188,7 +3188,7 @@ function _registry_check_code($type, $name = NULL) { $lookup_cache[$cache_key] = $file; if ($file) { - require_once DRUPAL_ROOT . '/' . $file; + include_once DRUPAL_ROOT . '/' . $file; return TRUE; } else { diff --git a/core/modules/config/config.admin.inc b/core/modules/config/config.admin.inc index 1fe14b2..87a1463 100644 --- a/core/modules/config/config.admin.inc +++ b/core/modules/config/config.admin.inc @@ -60,6 +60,21 @@ function config_admin_import_form($form, &$form_state) { $source_storage = new FileStorage(); $target_storage = new DatabaseStorage(); + // Prevent users from deleting all configuration. + // If the source storage is empty, that signals the unique condition of not + // having exported anything at all, and thus no valid storage to compare the + // active storage against. + // @todo StorageInterface::listAll() can easily yield hundreds or even + // thousands of entries; consider to add a dedicated isEmpty() method for + // storage controllers. + $all = $source_storage->listAll(); + if (empty($all)) { + form_set_error('', t('There is no base configuration. Export it first.', array( + '@export-url' => url('admin/config/development/sync/export'), + ))); + return $form; + } + config_admin_sync_form($form, $form_state, $source_storage, $target_storage); $form['actions'] = array('#type' => 'actions'); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php index 6b64b22..cdd2704 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php @@ -74,8 +74,14 @@ class ConfigImportUITest extends WebTestBase { $this->assertIdentical($file_storage->exists($name), FALSE, $name . ' not found.'); $this->assertIdentical($file_storage->exists($dynamic_name), FALSE, $dynamic_name . ' not found.'); - // Export. - config_export(); + // Verify that the import UI does not allow to import without exported + // configuration. + $this->drupalGet('admin/config/development/sync'); + $this->assertText('There is no base configuration.'); + + // Verify that the Export link yields to the export UI page, and export. + $this->clickLink('Export'); + $this->drupalPost(NULL, array(), t('Export')); // Create new configuration objects. $file_storage->write($name, array( @@ -111,6 +117,14 @@ class ConfigImportUITest extends WebTestBase { * Tests concurrent importing of configuration. */ function testImportLock() { + $name = 'config_test.new'; + + // Write a configuration object to import. + $file_storage = new FileStorage(); + $file_storage->write($name, array( + 'add_me' => 'new value', + )); + // Verify that there are configuration differences to import. $this->drupalGet('admin/config/development/sync'); $this->assertNoText(t('There are no configuration changes.'));