Issue #1889752 by alexpott: Fixed Remove unnecessary manifest creation in config_install_default_config().

8.0.x
webchick 2013-02-01 19:44:13 -08:00
parent 4fd0af5510
commit cfb1b5989e
4 changed files with 79 additions and 19 deletions

View File

@ -24,23 +24,17 @@ const CONFIG_IMPORT_LOCK = 'config_import';
* The name of the module or theme to install default configuration for.
*/
function config_install_default_config($type, $name) {
// If this module defines any ConfigEntity types then create an empty
// manifest file for each of them.
foreach (config_get_module_config_entities($name) as $entity_info) {
config('manifest.' . $entity_info['config_prefix'])->save();
}
$config_dir = drupal_get_path($type, $name) . '/config';
if (is_dir($config_dir)) {
$source_storage = new FileStorage($config_dir);
$target_storage = drupal_container()->get('config.storage');
// If this module defines any ConfigEntity types, then create a manifest file
// for each of them with a listing of the objects it maintains.
foreach (config_get_module_config_entities($name) as $entity_type => $entity_info) {
$manifest_config = config('manifest.' . $entity_info['config_prefix']);
$manifest_data = array();
foreach ($source_storage->listAll($entity_info['config_prefix']) as $config_name) {
list(, , $id) = explode('.', $config_name);
$manifest_data[$id]['name'] = $config_name;
}
$manifest_config->setData($manifest_data)->save();
}
$config_changes = array(
'delete' => array(),
'create' => array(),

View File

@ -35,6 +35,13 @@ class ConfigInstallTest extends DrupalUnitTestBase {
function testModuleInstallation() {
$default_config = 'config_test.system';
$default_configuration_entity = 'config_test.dynamic.default';
$default_config_manifest = 'manifest.config_test.dynamic';
$expected_manifest_data = array(
'default' => array(
'name' => 'config_test.dynamic.default',
),
);
$default_empty_config_manifest = 'manifest.config_test.empty_manifest';
// Verify that default module config does not exist before installation yet.
$config = config($default_config);
@ -42,6 +49,12 @@ class ConfigInstallTest extends DrupalUnitTestBase {
$config = config($default_configuration_entity);
$this->assertIdentical($config->isNew(), TRUE);
// Verify that configuration entity manifests do not exist.
$config = config($default_config_manifest);
$this->assertIdentical($config->isNew(), TRUE);
$config = config($default_empty_config_manifest);
$this->assertIdentical($config->isNew(), TRUE);
// Install the test module.
$this->enableModules(array('config_test'));
@ -51,6 +64,13 @@ class ConfigInstallTest extends DrupalUnitTestBase {
$config = config($default_configuration_entity);
$this->assertIdentical($config->isNew(), FALSE);
// Verify that configuration entity manifests have been created with
// expected contents.
$config = config($default_config_manifest);
$this->assertIdentical($config->get(), $expected_manifest_data);
$config = config($default_empty_config_manifest);
$this->assertIdentical($config->get(), array());
// Verify that configuration import callback was invoked for the dynamic
// configuration entity.
$this->assertTrue($GLOBALS['hook_config_import']);

View File

@ -0,0 +1,53 @@
<?php
/**
* @file
* Definition of Drupal\config_test\Plugin\Core\Entity\ConfigTestEmptyManifest.
*/
namespace Drupal\config_test\Plugin\Core\Entity;
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
/**
* Defines the ConfigTestEmptyManifest configuration entity.
*
* @Plugin(
* id = "config_test_empty_manifest",
* label = @Translation("Test empty manifest creation"),
* module = "config_test",
* controller_class = "Drupal\config_test\ConfigTestStorageController",
* config_prefix = "config_test.empty_manifest",
* entity_keys = {
* "id" = "id",
* "label" = "label",
* "uuid" = "uuid"
* }
* )
*/
class ConfigTestEmptyManifest extends ConfigEntityBase {
/**
* The machine name for the configuration entity.
*
* @var string
*/
public $id;
/**
* The UUID for the configuration entity.
*
* @var string
*/
public $uuid;
/**
* The human-readable name of the configuration entity.
*
* @var string
*/
public $label;
}

View File

@ -12,13 +12,6 @@ namespace Drupal\system\Tests\Database;
*/
class RegressionTest extends DatabaseTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('node');
public static function getInfo() {
return array(
'name' => 'Regression tests',