diff --git a/core/includes/config.inc b/core/includes/config.inc index 8d0eea1..8d37e13 100644 --- a/core/includes/config.inc +++ b/core/includes/config.inc @@ -1,5 +1,7 @@ $module_config_dir)); + $files = glob($module_config_dir . '/*.' . FileStorage::getFileExtension()); foreach ($files as $key => $file) { // Load config data into the active store and write it out to the @@ -47,10 +51,8 @@ function config_install_default_config($module) { // needs to be the same as the file name WITHOUT the extension. $config_name = basename($file, '.' . FileStorage::getFileExtension()); - $database_storage = new DatabaseStorage($config_name); - $file_storage = new FileStorage($config_name); - $file_storage->setPath($module_config_dir); - $database_storage->write($file_storage->read()); + $data = $module_file_storage->read($config_name); + $database_storage->write($config_name, $data); } } } @@ -73,16 +75,181 @@ function config_get_storage_names_with_prefix($prefix = '') { * The name of the configuration object to retrieve. The name corresponds to * a configuration file. For @code config(book.admin) @endcode, the config * object returned will contain the contents of book.admin configuration file. - * @param $class - * The class name of the config object to be returned. Defaults to - * DrupalConfig. * - * @return - * An instance of the class specified in the $class parameter. + * @return Drupal\Core\Config\ConfigObject + * A configuration object. + */ +function config($name) { + // @todo config needs to be a factory per name. Definition seems to support + // this somehow, but grepping the net didn't yield usable results. + return drupal_container()->get('config')->setName($name)->load(); +} + +/** + * Synchronizes configuration from FileStorage to DatabaseStorage. + */ +function config_sync() { + $config_changes = config_sync_get_changes(); + if (empty($config_changes)) { + return; + } + + if (!lock_acquire(__FUNCTION__)) { + // Another request is synchronizing configuration. + // Return a negative result for UI purposes. We do not make a difference + // between an actual synchronization error and a failed lock, because a + // concurrent request synchronizing configuration is an edge-case in the + // first place and would mean that more than one developer or site builder + // attempts to do it without coordinating with others. + return FALSE; + } + + try { + $remaining_changes = config_sync_invoke_sync_hooks($config_changes); + config_sync_save_changes($remaining_changes); + // Flush all caches and reset static variables after a successful import. + drupal_flush_all_caches(); + } + catch (ConfigException $e) { + watchdog_exception('config_sync', $e); + config_sync_invoke_sync_error_hooks($config_changes); + lock_release(__FUNCTION__); + return FALSE; + } + lock_release(__FUNCTION__); + return TRUE; +} + +/** + * Writes an array of config file changes to the active store. + * + * @param array $config_changes + * An array of changes to be written. + */ +function config_sync_save_changes(array $config_changes) { + // @todo Leverage DI + config.storage.info. + $source_storage = new FileStorage(); + $target_storage = new DatabaseStorage(); + foreach (array('delete', 'create', 'change') as $op) { + foreach ($config_changes[$op] as $name) { + if ($op == 'delete') { + $target_storage->delete($name); + } + else { + $data = $source_storage->read($name); + $target_storage->write($name, $data); + } + } + } +} + +/** + * Invokes hook_config_sync_validate() and hook_config_sync() implementations. + * + * @param array $config_changes + * An array of changes to be loaded. + */ +function config_sync_invoke_sync_hooks(array $config_changes) { + // @todo Leverage DI + config.storage.info. + $source_storage = new FileStorage(); + $target_storage = new DatabaseStorage(); + $storage_manager = drupal_container()->get('config.manager'); + + // Allow all modules to deny configuration changes. + // Note: module_invoke_all() can only be used as long as it does not allow + // implementations to take $config_changes by reference, since they are not + // supposed to change the configuration that is to be imported. + module_invoke_all('config_sync_validate', $config_changes, $target_storage, $source_storage); + + // Allow modules to take over configuration change operations for + // higher-level configuration data. + // First pass deleted, then new, and lastly changed configuration, in order to + // handle dependencies correctly. + $remaining_changes = $config_changes; + foreach (array('delete', 'create', 'change') as $op) { + foreach ($remaining_changes[$op] as $key => $name) { + // Extract owner from configuration object name. + $module = strtok($name, '.'); + // Check whether the module implements hook_config_sync() and ask it to + // handle the configuration change. + $handled_by_module = FALSE; + if (module_hook($module, 'config_sync')) { + $old_config = new ConfigObject($storage_manager); + $old_config->setName($name)->load(); + $data = $source_storage->read($name); + $new_config = new ConfigObject($storage_manager); + $new_config->setName($name)->setData($data); + $handled_by_module = module_invoke($module, 'config_sync', $op, $name, $new_config, $old_config); + } + if (!empty($handled_by_module)) { + unset($remaining_changes[$op][$key]); + } + } + } + + return $remaining_changes; +} + +/** + * Invokes hook_config_sync_error() implementations. + * + * During a sync run, modules may make changes that cannot be rolled back. + * This hook allows modules to react to an error that occurs after they have + * made such changes, and make sure that the state of configuration in the + * active store is correct. + * + * @param array $config_changes + * An array of changes to be loaded. + */ +function config_sync_invoke_sync_error_hooks(array $config_changes) { + // @todo Leverage DI + config.storage.info. + $source_storage = new FileStorage(); + $target_storage = new DatabaseStorage(); + + foreach (module_implements('config_sync_error') as $module) { + $function = $module . '_config_sync_error'; + try { + $function($config_changes, $target_storage, $source_storage); + } + catch (ConfigException $e) { + watchdog_exception('config_sync', $e); + // Just keep going, because we need to allow all modules to react even if + // some of them are behaving badly. + } + } +} + +/** + * Returns a list of differences between FileStorage and DatabaseStorage. * - * @todo Replace this with an appropriate factory / ability to inject in - * alternate storage engines.. + * @return array|bool + * The list of files changed on disk compared to the active store, or FALSE if + * there are no differences. */ -function config($name, $class = 'Drupal\Core\Config\DrupalConfig') { - return new $class(new DatabaseStorage($name)); +function config_sync_get_changes() { + // @todo Leverage DI + config.storage.info. + $source_storage = new FileStorage(); + $target_storage = new DatabaseStorage(); + + $source_names = $source_storage->getNamesWithPrefix(); + $target_names = $target_storage->getNamesWithPrefix(); + $config_changes = array( + 'create' => array_diff($source_names, $target_names), + 'change' => array(), + 'delete' => array_diff($target_names, $source_names), + ); + foreach (array_intersect($source_names, $target_names) as $name) { + $source_config_data = $source_storage->read($name); + $target_config_data = $target_storage->read($name); + if ($source_config_data != $target_config_data) { + $config_changes['change'][] = $name; + } + } + + // Do not trigger subsequent synchronization operations if there are no + // changes in either category. + if (empty($config_changes['create']) && empty($config_changes['change']) && empty($config_changes['delete'])) { + return FALSE; + } + return $config_changes; } diff --git a/core/includes/install.inc b/core/includes/install.inc index 1ebfb21..67ca802 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -1,7 +1,7 @@ delete(); - } + // Remove all configuration belonging to the module. + $config_names = DatabaseStorage::getNamesWithPrefix($module . '.'); + foreach ($config_names as $config_name) { + config($config_name)->delete(); } watchdog('system', '%module module uninstalled.', array('%module' => $module), WATCHDOG_INFO); diff --git a/core/includes/module.inc b/core/includes/module.inc index 928abc9..eb69bf5 100644 --- a/core/includes/module.inc +++ b/core/includes/module.inc @@ -487,7 +487,7 @@ function module_enable($module_list, $enable_dependencies = TRUE) { $versions = drupal_get_schema_versions($module); $version = $versions ? max($versions) : SCHEMA_INSTALLED; - // Copy any default configuration data to the system config directory/ + // Install default configuration of the module. config_install_default_config($module); // If the module has no current updates, but has some that were diff --git a/core/includes/update.inc b/core/includes/update.inc index f711507..a46f125 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -902,9 +902,8 @@ function update_variables_to_config($config_name, array $variable_map) { // Load and set default configuration values. // Throws a FileStorageReadException if there is no default configuration // file, which is required to exist. - $file = new FileStorage($config_name); - $file->setPath(drupal_get_path('module', $module) . '/config'); - $default_data = $file->read(); + $file = new FileStorage(array('directory' => drupal_get_path('module', $module) . '/config')); + $default_data = $file->read($config_name); // Merge any possibly existing original data into default values. // Only relevant when being called repetitively on the same config object. diff --git a/core/lib/Drupal/Core/Config/DrupalConfig.php b/core/lib/Drupal/Core/Config/ConfigObject.php similarity index 76% rename from core/lib/Drupal/Core/Config/DrupalConfig.php rename to core/lib/Drupal/Core/Config/ConfigObject.php index f5a9220..0884e9a 100644 --- a/core/lib/Drupal/Core/Config/DrupalConfig.php +++ b/core/lib/Drupal/Core/Config/ConfigObject.php @@ -2,20 +2,17 @@ namespace Drupal\Core\Config; -use Drupal\Core\Config\StorageInterface; -use Drupal\Core\Config\ConfigException; - /** - * Represents the default configuration storage object. + * Defines the default configuration object. */ -class DrupalConfig { +class ConfigObject { /** - * The storage engine to save this config object to. + * The name of the configuration object. * - * @var StorageInterface + * @var string */ - protected $storage; + protected $name; /** * The data of the configuration object. @@ -25,38 +22,35 @@ class DrupalConfig { protected $data = array(); /** - * Constructs a DrupalConfig object. + * The wrapping storage manager object. * - * @param StorageInterface $storage - * The storage engine where this config object should be saved. + * @var Drupal\Core\Config\StorageManager + */ + protected $storageManager; + + /** + * Constructs a configuration object. * - * @todo $this should really know about $name and make it publicly accessible. + * @param Drupal\Core\Config\StorageManager $storageManager + * The wrapping configuration manager object. */ - public function __construct(StorageInterface $storage) { - $this->storage = $storage; - $this->read(); + public function __construct(StorageManager $storageManager) { + $this->storageManager = $storageManager; } /** - * Reads config data from the active store into our object. + * Returns the name of this configuration object. */ - public function read() { - $data = $this->storage->read(); - $this->setData($data !== FALSE ? $data : array()); - return $this; + public function getName() { + return $this->name; } /** - * Checks whether a particular value is overridden. - * - * @param $key - * @todo - * - * @return - * @todo + * Sets the name of this configuration object. */ - public function isOverridden($key) { - return isset($this->_overrides[$key]); + public function setName($name) { + $this->name = $name; + return $this; } /** @@ -89,7 +83,7 @@ class DrupalConfig { public function get($key = '') { global $conf; - $name = $this->storage->getName(); + $name = $this->getName(); if (isset($conf[$name])) { $merged_data = drupal_array_merge_deep($this->data, $conf[$name]); } @@ -201,13 +195,27 @@ class DrupalConfig { else { drupal_array_unset_nested_value($this->data, $parts); } + return $this; + } + + /** + * Loads configuration data into this object. + */ + public function load() { + $this->setData(array()); + $data = $this->storageManager->selectStorage('read', $this->name)->read($this->name); + if ($data !== FALSE) { + $this->setData($data); + } + return $this; } /** * Saves the configuration object. */ public function save() { - $this->storage->write($this->data); + $this->storageManager->selectStorage('write', $this->name)->write($this->name, $this->data); + return $this; } /** @@ -215,6 +223,7 @@ class DrupalConfig { */ public function delete() { $this->data = array(); - $this->storage->delete(); + $this->storageManager->selectStorage('write', $this->name)->delete($this->name); + return $this; } } diff --git a/core/lib/Drupal/Core/Config/DatabaseStorage.php b/core/lib/Drupal/Core/Config/DatabaseStorage.php index c736245..27f5814 100644 --- a/core/lib/Drupal/Core/Config/DatabaseStorage.php +++ b/core/lib/Drupal/Core/Config/DatabaseStorage.php @@ -2,25 +2,52 @@ namespace Drupal\Core\Config; -use Drupal\Core\Config\StorageBase; +use Drupal\Core\Config\StorageInterface; +use Drupal\Core\Database\Database; use Exception; /** - * Represents an SQL-based configuration storage object. + * Defines the Database storage controller. */ -class DatabaseStorage extends StorageBase { +class DatabaseStorage implements StorageInterface { + + /** + * Database connection options for this storage controller. + * + * - target: The connection to use for storage operations. + * + * @var array + */ + protected $options; + + /** + * Implements StorageInterface::__construct(). + */ + public function __construct(array $info = array()) { + $info += array( + 'target' => 'default', + ); + $this->options = $info; + } + + /** + * Returns the database connection to use. + */ + protected function getConnection() { + return Database::getConnection($this->options['target']); + } /** * Implements StorageInterface::read(). */ - public function read() { + public function read($name) { // There are situations, like in the installer, where we may attempt a // read without actually having the database available. In this case, // catch the exception and just return an empty array so the caller can // handle it if need be. $data = array(); try { - $raw = db_query('SELECT data FROM {config} WHERE name = :name', array(':name' => $this->name))->fetchField(); + $raw = $this->getConnection()->query('SELECT data FROM {config} WHERE name = :name', array(':name' => $name), $this->options)->fetchField(); if ($raw !== FALSE) { $data = $this->decode($raw); } @@ -31,22 +58,22 @@ class DatabaseStorage extends StorageBase { } /** - * Implements StorageInterface::writeToActive(). + * Implements StorageInterface::write(). */ - public function writeToActive($data) { + public function write($name, array $data) { $data = $this->encode($data); - return db_merge('config') - ->key(array('name' => $this->name)) + return $this->getConnection()->merge('config', $this->options) + ->key(array('name' => $name)) ->fields(array('data' => $data)) ->execute(); } /** - * @todo + * Implements StorageInterface::delete(). */ - public function deleteFromActive() { - db_delete('config') - ->condition('name', $this->name) + public function delete($name) { + $this->getConnection()->delete('config', $this->options) + ->condition('name', $name) ->execute(); } diff --git a/core/lib/Drupal/Core/Config/FileStorage.php b/core/lib/Drupal/Core/Config/FileStorage.php index 2a6d448..4eaadd9 100644 --- a/core/lib/Drupal/Core/Config/FileStorage.php +++ b/core/lib/Drupal/Core/Config/FileStorage.php @@ -2,58 +2,31 @@ namespace Drupal\Core\Config; +use Drupal\Core\Config\StorageInterface; use Symfony\Component\Yaml\Yaml; /** - * Represents the file storage controller. - * - * @todo Implement StorageInterface after removing DrupalConfig methods. - * @todo Consider to extend StorageBase. + * Defines the file storage controller. */ -class FileStorage { +class FileStorage implements StorageInterface { /** - * The name of the configuration object. + * Configuration options for this storage controller. * - * @var string - */ - protected $name; - - /** - * The filesystem path containing the configuration object. + * - directory: The filesystem path for configuration objects. * - * @var string + * @var array */ - protected $path; + protected $info; /** * Implements StorageInterface::__construct(). */ - public function __construct($name = NULL) { - $this->name = $name; - } - - /** - * Returns the path containing the configuration file. - * - * @return string - * The relative path to the configuration object. - */ - public function getPath() { - // If the path has not been set yet, retrieve and assign the default path - // for configuration files. - if (!isset($this->path)) { - $this->setPath(config_get_config_directory()); + public function __construct(array $info = array()) { + if (!isset($info['directory'])) { + $info['directory'] = config_get_config_directory(); } - return $this->path; - } - - /** - * Sets the path containing the configuration file. - */ - public function setPath($directory) { - $this->path = $directory; - return $this; + $this->info = $info; } /** @@ -62,8 +35,8 @@ class FileStorage { * @return string * The path to the configuration file. */ - public function getFilePath() { - return $this->getPath() . '/' . $this->getName() . '.' . self::getFileExtension(); + public function getFilePath($name) { + return $this->info['directory'] . '/' . $name . '.' . self::getFileExtension(); } /** @@ -82,8 +55,8 @@ class FileStorage { * @return bool * TRUE if the configuration file exists, FALSE otherwise. */ - protected function exists() { - return file_exists($this->getFilePath()); + public function exists($name) { + return file_exists($this->getFilePath($name)); } /** @@ -91,11 +64,12 @@ class FileStorage { * * @throws FileStorageException */ - public function write($data) { + public function write($name, array $data) { $data = $this->encode($data); - if (!file_put_contents($this->getFilePath(), $data)) { - throw new FileStorageException('Failed to write configuration file: ' . $this->getFilePath()); + if (!file_put_contents($this->getFilePath($name), $data)) { + throw new FileStorageException('Failed to write configuration file: ' . $this->getFilePath($name)); } + return $this; } /** @@ -103,15 +77,15 @@ class FileStorage { * * @throws FileStorageReadException */ - public function read() { - if (!$this->exists()) { - throw new FileStorageReadException("Configuration file '$this->name' does not exist."); + public function read($name) { + if (!$this->exists($name)) { + throw new FileStorageReadException("Configuration file '$name' does not exist."); } - $data = file_get_contents($this->getFilePath()); + $data = file_get_contents($this->getFilePath($name)); $data = $this->decode($data); if ($data === FALSE) { - throw new FileStorageReadException("Failed to decode configuration file '$this->name'."); + throw new FileStorageReadException("Failed to decode configuration file '$name'."); } return $data; } @@ -119,9 +93,9 @@ class FileStorage { /** * Deletes a configuration file. */ - public function delete() { - // Needs error handling and etc. - @drupal_unlink($this->getFilePath()); + public function delete($name) { + // @todo Error handling. + return @drupal_unlink($this->getFilePath($name)); } /** @@ -144,25 +118,11 @@ class FileStorage { } /** - * Implements StorageInterface::getName(). - */ - public function getName() { - return $this->name; - } - - /** - * Implements StorageInterface::setName(). - */ - public function setName($name) { - $this->name = $name; - } - - /** * Implements StorageInterface::getNamesWithPrefix(). + * + * @todo Allow to search for files in custom paths. */ public static function getNamesWithPrefix($prefix = '') { - // @todo Use $this->getPath() to allow for contextual search of files in - // custom paths. $files = glob(config_get_config_directory() . '/' . $prefix . '*.' . FileStorage::getFileExtension()); $clean_name = function ($value) { return basename($value, '.' . FileStorage::getFileExtension()); diff --git a/core/lib/Drupal/Core/Config/StorageBase.php b/core/lib/Drupal/Core/Config/StorageBase.php deleted file mode 100644 index b03ff27..0000000 --- a/core/lib/Drupal/Core/Config/StorageBase.php +++ /dev/null @@ -1,121 +0,0 @@ -name = $name; - } - - /** - * Instantiates a new file storage object or returns the existing one. - * - * @return Drupal\Core\Config\FileStorage - * The file object for this configuration object. - */ - protected function fileStorage() { - if (!isset($this->fileStorage)) { - $this->fileStorage = new FileStorage($this->name); - } - return $this->fileStorage; - } - - /** - * Implements StorageInterface::copyToFile(). - */ - public function copyToFile() { - return $this->writeToFile($this->read()); - } - - /** - * Implements StorageInterface::deleteFile(). - */ - public function deleteFile() { - return $this->fileStorage()->delete(); - } - - /** - * Implements StorageInterface::copyFromFile(). - */ - public function copyFromFile() { - return $this->writeToActive($this->readFromFile()); - } - - /** - * @todo - * - * @return - * @todo - */ - public function readFromFile() { - return $this->fileStorage()->read($this->name); - } - - /** - * Implements StorageInterface::isOutOfSync(). - */ - public function isOutOfSync() { - return $this->read() !== $this->readFromFile(); - } - - /** - * Implements StorageInterface::write(). - */ - public function write($data) { - $this->writeToActive($data); - $this->writeToFile($data); - } - - /** - * Implements StorageInterface::writeToFile(). - */ - public function writeToFile($data) { - return $this->fileStorage()->write($data); - } - - /** - * Implements StorageInterface::delete(). - */ - public function delete() { - $this->deleteFromActive(); - $this->deleteFile(); - } - - /** - * Implements StorageInterface::getName(). - */ - public function getName() { - return $this->name; - } - - /** - * Implements StorageInterface::setName(). - */ - public function setName($name) { - $this->name = $name; - } -} diff --git a/core/lib/Drupal/Core/Config/StorageInterface.php b/core/lib/Drupal/Core/Config/StorageInterface.php index 43141a5..e3ed848 100644 --- a/core/lib/Drupal/Core/Config/StorageInterface.php +++ b/core/lib/Drupal/Core/Config/StorageInterface.php @@ -7,74 +7,43 @@ namespace Drupal\Core\Config; * * Classes implementing this interface allow reading and writing configuration * data from and to the storage. - * - * @todo Remove all active/file methods. They belong onto DrupalConfig only. */ interface StorageInterface { /** - * Constructs a storage manipulation class. + * Constructs the storage controller. * - * @param string $name - * (optional) The name of a configuration object to load. - */ - function __construct($name = NULL); - - /** - * Reads the configuration data from the storage. - */ - function read(); - - /** - * Copies the configuration data from the storage into a file. + * @param array $info + * An associative array containing configuration options specific to the + * storage controller. */ - function copyToFile(); + public function __construct(array $info = array()); /** - * Copies the configuration data from the file into the storage. - */ - function copyFromFile(); - - /** - * Deletes the configuration data file. - */ - function deleteFile(); - - /** - * Checks whether the file and the storage is in sync. + * Reads configuration data from the storage. * - * @return - * TRUE if the file and the storage contains the same data, FALSE - * if not. + * @param string $name + * The name of a configuration object to load. */ - function isOutOfSync(); + public function read($name); /** - * Writes the configuration data into the active storage and the file. + * Writes configuration data to the storage. * - * @param $data + * @param string $name + * The name of a configuration object to save. + * @param array $data * The configuration data to write. */ - function write($data); - - /** - * Writes the configuration data into the active storage but not the file. - * - * Use this function if you need to make temporary changes to your - * configuration. - * - * @param $data - * The configuration data to write into active storage. - */ - function writeToActive($data); + public function write($name, array $data); /** - * Writes the configuration data into the file. + * Deletes a configuration object from the storage. * - * @param $data - * The configuration data to write into the file. + * @param string $name + * The name of a configuration object to delete. */ - function writeToFile($data); + public function delete($name); /** * Encodes configuration data into the storage-specific format. @@ -105,16 +74,6 @@ interface StorageInterface { public static function decode($raw); /** - * Gets the name of this object. - */ - public function getName(); - - /** - * Sets the name of this object. - */ - public function setName($name); - - /** * Gets configuration object names starting with a given prefix. * * Given the following configuration objects: diff --git a/core/lib/Drupal/Core/Config/StorageManager.php b/core/lib/Drupal/Core/Config/StorageManager.php new file mode 100644 index 0000000..82afe01 --- /dev/null +++ b/core/lib/Drupal/Core/Config/StorageManager.php @@ -0,0 +1,98 @@ + array( + * 'target' => 'default', + * 'read' => TRUE, + * 'write' => TRUE, + * ), + * 'Drupal\Core\Config\FileStorage' => array( + * 'directory' => 'sites/default/files/config', + * 'read' => TRUE, + * 'write' => FALSE, + * ), + * ) + * @endcode + */ + public function __construct(array $storage_info) { + $this->storageInfo = $storage_info; + } + + /** + * Returns a storage controller to use for a given operation. + * + * Handles the core functionality of the configuration manager by determining + * which storage can handle a particular configuration object, depending on + * the operation being performed. + * + * @param string $access_operation + * The operation access level; either 'read' or 'write'. Use 'write' both + * for saving and deleting configuration. + * @param string $name + * The name of the configuration object that is operated on. + */ + public function selectStorage($access_operation, $name) { + // Determine the appropriate storage controller to use. + // Take the first defined storage that allows $op. + foreach ($this->storageInfo as $class => $storage_config) { + if (!empty($storage_config[$access_operation])) { + $storage_class = $class; + break; + } + } + if (!isset($storage_class)) { + throw new ConfigException("Failed to find storage controller that allows $access_operation access for $name."); + } + + // Instantiate a new storage controller object, if there is none yet. + if (!isset($this->storageInstances[$storage_class])) { + $this->storageInstances[$storage_class] = new $storage_class($this->storageInfo[$storage_class]); + } + return $this->storageInstances[$storage_class]; + } +} diff --git a/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php b/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php index b9b3431..34407c2 100644 --- a/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php +++ b/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php @@ -8,6 +8,8 @@ namespace Drupal\Core\DependencyInjection; use Symfony\Component\DependencyInjection\ContainerBuilder as BaseContainerBuilder; +use Symfony\Component\DependencyInjection\Reference; + /** * Drupal's dependency injection container. @@ -24,5 +26,29 @@ class ContainerBuilder extends BaseContainerBuilder { // functions. This default is overridden by drupal_language_initialize() // during language negotiation. $this->register(LANGUAGE_TYPE_INTERFACE, 'Drupal\\Core\\Language\\Language'); + + // Register configuration system manager. + $this->setParameter('config.storage.manager', 'Drupal\Core\Config\StorageManager'); + $this->setParameter('config.storage.info', array( + 'Drupal\Core\Config\DatabaseStorage' => array( + 'target' => 'default', + 'read' => TRUE, + 'write' => TRUE, + ), + 'Drupal\Core\Config\FileStorage' => array( + 'directory' => config_get_config_directory(), + 'read' => TRUE, + 'write' => FALSE, + ), + )); + $this->register('config.manager', '%config.storage.manager%') + ->addArgument('%config.storage.info%'); + + // Register configuration system. + // @todo config needs to be a factory per name. Definition seems to support + // this somehow, but grepping the net didn't yield usable results. + $this->setParameter('config.object', 'Drupal\Core\Config\ConfigObject'); + $this->register('config', '%config.object%') + ->addArgument(new Reference('config.manager')); } } diff --git a/core/modules/config/config.admin.inc b/core/modules/config/config.admin.inc new file mode 100644 index 0000000..2366c5a --- /dev/null +++ b/core/modules/config/config.admin.inc @@ -0,0 +1,62 @@ + t('There are no configuration changes.'), + ); + return $form; + } + + foreach ($config_changes as $config_change_type => $config_files) { + if (empty($config_files)) { + continue; + } + $form[$config_change_type] = array( + '#type' => 'fieldset', + '#title' => $config_change_type . ' (' . count($config_files) . ')', + '#collapsible' => TRUE, + ); + $form[$config_change_type]['config_files'] = array( + '#theme' => 'table', + '#header' => array('Name'), + ); + foreach ($config_files as $config_file) { + $form[$config_change_type]['config_files']['#rows'][] = array($config_file); + } + } + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Import'), + ); + return $form; +} + +/** + * Form submission handler for config_admin_import_form(). + */ +function config_admin_import_form_submit($form, &$form_state) { + if (config_sync()) { + drupal_set_message(t('The configuration was imported successfully.')); + } + else { + // Another request may be synchronizing configuration already. Wait for it + // to complete before returning the error, so already synchronized changes + // do not appear again. + lock_wait(__FUNCTION__); + drupal_set_message(t('The import failed due to an error. Any errors have been logged.'), 'error'); + } +} + diff --git a/core/modules/config/config.api.php b/core/modules/config/config.api.php new file mode 100644 index 0000000..7e92658 --- /dev/null +++ b/core/modules/config/config.api.php @@ -0,0 +1,112 @@ +load() to load a + * configuration object. + * @param $source_storage + * A configuration class acting on the source storage from which configuration + * differences were read. Use $target_storage->load() to load a configuration + * object. + * + * @throws ConfigException + * In case a configuration change cannot be allowed. + */ +function hook_config_sync_validate($config_changes, $target_storage, $source_storage) { + // Deny changes to our settings. + if (isset($config_changes['change']['mymodule.locked'])) { + throw new ConfigException('MyModule settings cannot be changed.'); + } +} + +/** + * Synchronize configuration changes. + * + * This hook is invoked when configuration is synchronized between storages and + * allows a module to take over the synchronization of configuration data. + * + * Modules should implement this hook if they manage higher-level configuration + * data (such as image styles, node types, or fields), which needs to be + * prepared and passed through module API functions to properly handle a + * configuration change. + * + * @param string $op + * The operation to perform for the configuration data; one of 'create', + * 'delete', or 'change'. + * @param string $name + * The name of the configuration object. + * @param Drupal\Core\Config\DrupalConfig $new_config + * A configuration class acting on the target storage to which the new + * configuration will be written. Use $target_storage->load() to load a + * configuration object. + * @param Drupal\Core\Config\DrupalConfig $old_config + * A configuration class acting on the source storage from which configuration + * differences were read. Use $target_storage->load() to load a configuration + * object. + */ +function hook_config_sync($op, $name, $new_config, $old_config) { + // Only image styles require custom handling. Any other module settings can be + // synchronized directly. + if (strpos($name, 'image.style.') !== 0) { + return FALSE; + } + + if ($op == 'delete') { + $style = $old_config->get(); + return image_style_delete($style); + } + if ($op == 'new') { + $style = $new_config->get(); + return image_style_save($style); + } + if ($op == 'change') { + $style = $new_config->get(); + return image_style_save($style); + } +} + +/** + * Validate configuration changes before they are saved to the active store. + * + * During synchronization of configuration, modules may make changes that cannot + * be rolled back. This hook allows modules to react to an error that occurs + * after they have made such changes, and make sure that the state of + * configuration is as correct as possible. + * + * @param array $config_changes + * An associative array whose keys denote the configuration differences + * ('create', 'change', 'delete') and whose values are arrays of configuration + * object names. + * @param $target_storage + * A configuration class acting on the target storage to which the new + * configuration will be written. Use $target_storage->load() to load a + * configuration object. + * @param $source_storage + * A configuration class acting on the source storage from which configuration + * differences were read. Use $target_storage->load() to load a configuration + * object. + */ +function hook_config_sync_error($config_changes, $target_storage, $source_storage) { + // @todo Feasability and usage of this hook is still unclear, without having a + // backup of $target_storage at hand. +} + diff --git a/core/modules/config/config.module b/core/modules/config/config.module index b3d9bbc..3d4fcfe 100644 --- a/core/modules/config/config.module +++ b/core/modules/config/config.module @@ -1 +1,33 @@ t('Import configuration'), + 'restrict access' => TRUE, + ); + return $permissions; +} + +/** + * Implements hook_menu(). + */ +function config_menu() { + $items['admin/config/development/import'] = array( + 'title' => 'Import configuration', + 'description' => 'Import and synchronize configuration changes.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('config_admin_import_form'), + 'access arguments' => array('import configuration'), + 'file' => 'config.admin.inc', + ); + return $items; +} + diff --git a/core/modules/config/config_test/config/config_test.delete.yml b/core/modules/config/config_test/config/config_test.delete.yml new file mode 100644 index 0000000..b8ccb67 --- /dev/null +++ b/core/modules/config/config_test/config/config_test.delete.yml @@ -0,0 +1 @@ +delete_me: bar diff --git a/core/modules/config/config_test/config/config_test.system.yml b/core/modules/config/config_test/config/config_test.system.yml new file mode 100644 index 0000000..20e9ff3 --- /dev/null +++ b/core/modules/config/config_test/config/config_test.system.yml @@ -0,0 +1 @@ +foo: bar diff --git a/core/modules/config/config_test/config_test.info b/core/modules/config/config_test/config_test.info new file mode 100644 index 0000000..8735450 --- /dev/null +++ b/core/modules/config/config_test/config_test.info @@ -0,0 +1,6 @@ +name = Configuration test module +package = Core +version = VERSION +core = 8.x +dependencies[] = config +hidden = TRUE diff --git a/core/modules/config/config_test/config_test.module b/core/modules/config/config_test/config_test.module new file mode 100644 index 0000000..8af386e --- /dev/null +++ b/core/modules/config/config_test/config_test.module @@ -0,0 +1,36 @@ + 'CRUD operations', + 'description' => 'Tests CRUD operations on configuration objects.', + 'group' => 'Configuration', + ); + } + + /** + * Tests CRUD operations. + */ + function testCRUD() { + $storage = new DatabaseStorage(); + $name = 'config_test.crud'; + + // Create a new configuration object. + $config = config($name); + $config->set('value', 'initial'); + $config->save(); + + // Verify the active store contains the saved value. + $actual_data = $storage->read($name); + $this->assertIdentical($actual_data, array('value' => 'initial')); + + // Update the configuration object instance. + $config->set('value', 'instance-update'); + $config->save(); + + // Verify the active store contains the updated value. + $actual_data = $storage->read($name); + $this->assertIdentical($actual_data, array('value' => 'instance-update')); + + // Verify a call to config() immediately returns the updated value. + $new_config = config($name); + $this->assertIdentical($new_config->get(), $config->get()); + + // Verify config() returned the existing config instance. + $this->assertIdentical($new_config, $config); + + // Delete the configuration object. + $config->delete(); + + // Verify the configuration object is empty. + $this->assertIdentical($config->get(), array()); + + // Verify the active store contains no value. + $actual_data = $storage->read($name); + $this->assertIdentical($actual_data, array()); + + // Verify config() returns no data. + $new_config = config($name); + $this->assertIdentical($new_config->get(), $config->get()); + + // Verify config() returned the existing config instance. + $this->assertIdentical($new_config, $config); + + // Re-create the configuration object. + $config->set('value', 're-created'); + $config->save(); + + // Verify the active store contains the updated value. + $actual_data = $storage->read($name); + $this->assertIdentical($actual_data, array('value' => 're-created')); + + // Verify a call to config() immediately returns the updated value. + $new_config = config($name); + $this->assertIdentical($new_config->get(), $config->get()); + + // Verify config() returned the existing config instance. + $this->assertIdentical($new_config, $config); + } +} diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigFileContentTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigFileContentTest.php index bfd27ac..42fcfb6 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigFileContentTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigFileContentTest.php @@ -7,6 +7,7 @@ namespace Drupal\config\Tests; +use Drupal\Core\Config\DatabaseStorage; use Drupal\Core\Config\FileStorage; use Drupal\simpletest\WebTestBase; @@ -34,7 +35,6 @@ class ConfigFileContentTest extends WebTestBase { * Tests setting, writing, and reading of a configuration setting. */ function testReadWriteConfig() { - $config_dir = config_get_config_directory(); $name = 'foo.bar'; $key = 'foo'; $value = 'bar'; @@ -62,7 +62,7 @@ class ConfigFileContentTest extends WebTestBase { $config = config($name); // Verify an configuration object is returned. -// $this->assertEqual($config->name, $name); + $this->assertEqual($config->getName(), $name); $this->assertTrue($config, t('Config object created.')); // Verify the configuration object is empty. @@ -71,7 +71,6 @@ class ConfigFileContentTest extends WebTestBase { // Verify nothing was saved. $db_config = db_query('SELECT * FROM {config} WHERE name = :name', array(':name' => $name))->fetch(); $this->assertIdentical($db_config, FALSE, t('Active store does not have a record for %name', array('%name' => $name))); - $this->assertFalse(file_exists($config_dir . '/' . $name . '.' . $this->fileExtension), 'Configuration file does not exist.'); // Add a top level value $config = config($name); @@ -100,9 +99,6 @@ class ConfigFileContentTest extends WebTestBase { $db_config = db_query('SELECT * FROM {config} WHERE name = :name', array(':name' => $name))->fetch(); $this->assertEqual($db_config->name, $name, t('After saving configuration, active store has a record for %name', array('%name' => $name))); - // Verify the file exists. - $this->assertTrue(file_exists($config_dir . '/' . $name . '.' . $this->fileExtension), t('After saving configuration, config file exists.')); - // Read top level value $config = config($name); // $this->assertEqual($config->name, $name); @@ -161,27 +157,24 @@ class ConfigFileContentTest extends WebTestBase { $db_config = db_query('SELECT * FROM {config} WHERE name = :name', array(':name' => $chained_name))->fetch(); $this->assertEqual($db_config->name, $chained_name, t('After saving configuration by chaining through set(), active store has a record for %name', array('%name' => $chained_name))); - // Verify the file exists from a chained save. - $this->assertTrue(file_exists($config_dir . '/' . $chained_name . '.' . $this->fileExtension), t('After saving configuration by chaining through set(), config file exists.')); - // Get file listing for all files starting with 'foo'. Should return // two elements. - $files = FileStorage::getNamesWithPrefix('foo'); + $files = DatabaseStorage::getNamesWithPrefix('foo'); $this->assertEqual(count($files), 2, 'Two files listed with the prefix \'foo\'.'); // Get file listing for all files starting with 'biff'. Should return // one element. - $files = FileStorage::getNamesWithPrefix('biff'); + $files = DatabaseStorage::getNamesWithPrefix('biff'); $this->assertEqual(count($files), 1, 'One file listed with the prefix \'biff\'.'); // Get file listing for all files starting with 'foo.bar'. Should return // one element. - $files = FileStorage::getNamesWithPrefix('foo.bar'); + $files = DatabaseStorage::getNamesWithPrefix('foo.bar'); $this->assertEqual(count($files), 1, 'One file listed with the prefix \'foo.bar\'.'); // Get file listing for all files starting with 'bar'. Should return // an empty array. - $files = FileStorage::getNamesWithPrefix('bar'); + $files = DatabaseStorage::getNamesWithPrefix('bar'); $this->assertEqual($files, array(), 'No files listed with the prefix \'bar\'.'); // Delete the configuration. @@ -191,9 +184,6 @@ class ConfigFileContentTest extends WebTestBase { // Verify the database entry no longer exists. $db_config = db_query('SELECT * FROM {config} WHERE name = :name', array(':name' => $name))->fetch(); $this->assertIdentical($db_config, FALSE); - $this->assertFalse(file_exists($config_dir . '/' . $name . $this->fileExtension)); - - // Attempt to delete non-existing configuration. } /** @@ -216,17 +206,10 @@ class ConfigFileContentTest extends WebTestBase { 'invalid xml' => ' & < > " \' ', ); - // Attempt to read non-existing configuration. - $config = config($name); - - foreach ($config_data as $key => $value) { - $config->set($key, $value); - } - - $config->save(); - - $config_filestorage = new FileStorage($name); - $config_parsed = $config_filestorage->read(); + // Encode and write, and reload and decode the configuration data. + $filestorage = new FileStorage(); + $filestorage->write($name, $config_data); + $config_parsed = $filestorage->read($name); $key = 'numeric keys'; $this->assertIdentical($config_data[$key], $config_parsed[$key]); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigFileSecurityTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigFileSecurityTest.php deleted file mode 100644 index 5f9ec07..0000000 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigFileSecurityTest.php +++ /dev/null @@ -1,51 +0,0 @@ - 'Good morning, Denver!'); - - public static function getInfo() { - return array( - 'name' => 'File security', - 'description' => 'Tests security of saved configuration files.', - 'group' => 'Configuration', - ); - } - - /** - * Tests that a file written by this system can be successfully read back. - */ - function testFilePersist() { - $file = new FileStorage($this->filename); - $file->write($this->testContent); - - unset($file); - - // Reading should throw an exception in case of bad validation. - // Note that if any other exception is thrown, we let the test system - // handle catching and reporting it. - try { - $file = new FileStorage($this->filename); - $saved_content = $file->read(); - - $this->assertEqual($saved_content, $this->testContent); - } - catch (Exception $e) { - $this->fail('File failed verification when being read.'); - } - } -} diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php new file mode 100644 index 0000000..569b3c6 --- /dev/null +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php @@ -0,0 +1,149 @@ + 'Import configuration', + 'description' => 'Tests importing configuration from files into active store.', + 'group' => 'Configuration', + ); + } + + function setUp() { + parent::setUp('config_test'); + $this->fileExtension = FileStorage::getFileExtension(); + } + + /** + * Tests deletion of configuration during import. + */ + function testDeleted() { + $name = 'config_test.system'; + + // Verify the default configuration value exists. + $config = config($name); + $this->assertIdentical($config->get('foo'), 'bar'); + + // Delete the configuration object. + $file = new FileStorage(); + $file->delete($name); + + // Import. + config_sync(); + + // Verify the value has disappeared. + $config = config($name); + $this->assertIdentical($config->get('foo'), NULL); + } + + /** + * Tests creation of configuration during import. + */ + function testNew() { + $name = 'config_test.new'; + + // Verify the configuration to create does not exist yet. + $file = new FileStorage(); + $this->assertIdentical($file->exists($name), FALSE, $name . ' not found.'); + + // Create a new configuration object. + $file->write($name, array( + 'add_me' => 'new value', + )); + $this->assertIdentical($file->exists($name), TRUE, $name . ' found.'); + + // Import. + config_sync(); + + // Verify the value has appeared. + $config = config($name); + $this->assertIdentical($config->get('add_me'), 'new value'); + } + + /** + * Tests updating of configuration during import. + */ + function testUpdated() { + $name = 'config_test.system'; + + // Replace the file content of the existing configuration object. + $file = new FileStorage(); + $this->assertIdentical($file->exists($name), TRUE, $name . ' found.'); + $file->write($name, array( + 'foo' => 'beer', + )); + + // Verify the active store still returns the default value. + $config = config($name); + $this->assertIdentical($config->get('foo'), 'bar'); + + // Import. + config_sync(); + + // Verify the value was updated. + $config = config($name); + $this->assertIdentical($config->get('foo'), 'beer'); + } + + /** + * Tests config_sync() hook invocations. + */ + function testSyncHooks() { + $name = 'config_test.system'; + + // Delete a file so that hook_config_sync() hooks are run. + $file = new FileStorage(); + $this->assertIdentical($file->exists($name), TRUE, $name . ' found.'); + $file->delete($name); + + // Make the test implementation throw an error during synchronization, so + // hook_config_sync_error() is also invoked. + $GLOBALS['config_sync_throw_error'] = TRUE; + + // Import. + config_sync(); + + // Verify hook_config_sync() was invoked. + $this->assertIdentical($GLOBALS['hook_config_sync'], 'config_test_config_sync'); + // Verify hook_config_sync_error() was invoked. + $this->assertIdentical($GLOBALS['hook_config_sync_validate'], 'config_test_config_sync_validate'); + // Verify hook_config_sync_error() was invoked. + $this->assertIdentical($GLOBALS['hook_config_sync_error'], 'config_test_config_sync_error'); + } + + /** + * Tests abort of import upon validation error. + */ + function testSyncValidationError() { + $name = 'config_test.system'; + + // Delete a file so that hook_config_sync() hooks are run. + $file = new FileStorage(); + $this->assertIdentical($file->exists($name), TRUE, $name . ' found.'); + $file->delete($name); + + // Make the test implementation throw a validation error, aborting the + // synchronization. + $GLOBALS['config_sync_validate_throw_error'] = TRUE; + + // Import. + config_sync(); + + // Verify the active store was not updated. + $config = config($name); + $this->assertIdentical($config->get('foo'), 'bar'); + } +} diff --git a/core/modules/image/image.module b/core/modules/image/image.module index 905e6a7..7825a18 100644 --- a/core/modules/image/image.module +++ b/core/modules/image/image.module @@ -500,6 +500,36 @@ function image_path_flush($path) { } /** + * Implements hook_config_sync(). + */ +function image_config_sync($op, $name, $new_config, $old_config) { + // Only image styles require custom handling. Any other module settings can be + // synchronized directly. + if (strpos($name, 'image.style.') !== 0) { + return FALSE; + } + + if ($op == 'delete') { + // @todo image_style_delete() supports the notion of a "replacement style" + // to be used by other modules instead of the deleted style. Good idea. + // But squeezing that into a "delete" operation is the worst idea ever. + // Regardless of Image module insanity, add a 'replaced' stack to + // config_sync()? And how can that work? If an 'old_ID' key would be a + // standard, wouldn't this belong into 'changed' instead? + $style = $old_config->get(); + return image_style_delete($style); + } + if ($op == 'new') { + $style = $new_config->get(); + return image_style_save($style); + } + if ($op == 'change') { + $style = $new_config->get(); + return image_style_save($style); + } +} + +/** * Get an array of all styles and their settings. * * @return diff --git a/core/modules/system/system.info b/core/modules/system/system.info index 4628b7f..37593ba 100644 --- a/core/modules/system/system.info +++ b/core/modules/system/system.info @@ -9,19 +9,13 @@ configure = admin/config/system ; Tests in tests directory. files[] = tests/cache.test -files[] = tests/common.test files[] = tests/database.test files[] = tests/file.test files[] = tests/filetransfer.test files[] = tests/form.test files[] = tests/image.test -files[] = tests/menu.test -files[] = tests/module.test -files[] = tests/pager.test files[] = tests/registry.test -files[] = tests/schema.test files[] = tests/symfony.test -files[] = tests/tablesort.test files[] = tests/theme.test files[] = tests/update.test files[] = tests/uuid.test diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 39755dc..58e7605 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -376,7 +376,8 @@ function system_element_info() { $types['email'] = array( '#input' => TRUE, '#size' => 60, - '#maxlength' => EMAIL_MAX_LENGTH, + // user.module is not loaded in case of early bootstrap errors. + '#maxlength' => defined('EMAIL_MAX_LENGTH') ? EMAIL_MAX_LENGTH : 255, '#autocomplete_path' => FALSE, '#process' => array('form_process_autocomplete', 'ajax_process_form', 'form_process_pattern'), '#element_validate' => array('form_validate_email'), diff --git a/core/modules/system/system.test b/core/modules/system/system.test index 17b96c8..80cde8b 100644 --- a/core/modules/system/system.test +++ b/core/modules/system/system.test @@ -1,6 +1,7 @@ assertTrue($files); - $config_dir = config_get_config_directory(); - // Get the filename of each config file. - foreach ($files as $file) { - $parts = explode('/', $file); - $filename = array_pop($parts); - if (!file_exists($config_dir . '/' . $filename)) { - $files_exist = FALSE; - } - } + if (!is_dir($module_config_dir)) { + return; } + $files = glob($module_config_dir . '/*.' . FileStorage::getFileExtension()); + + // Verify that the config directory is not empty. + $this->assertTrue($files); - return $this->assertTrue($files_exist, t('All config files defined by the @module module have been copied to the live config directory.', array('@module' => $module))); + // Check whether each default configuration object exists in the active + // store, and if so, remove it from the stack. + foreach ($files as $key => $file) { + $name = basename($file, '.' . FileStorage::getFileExtension()); + if (config($name)->get()) { + unset($files[$key]); + } + } + // Verify that all configuration has been installed (which means that $files + // is empty). + return $this->assertFalse($files, format_string('Default configuration of @module module found.', array('@module' => $module))); } /** - * Assert that none of a module's default config files are loaded. + * Asserts that no configuration exists for a given module. * * @param string $module * The name of the module. * * @return bool - * TRUE if the module's config files do not exist, FALSE otherwise. + * TRUE if no configuration was found, FALSE otherwise. */ - function assertModuleConfigFilesDoNotExist($module) { - // Define test variable. - $files_exist = FALSE; - // Get the path to the module's config dir. - $module_config_dir = drupal_get_path('module', $module) . '/config'; - if (is_dir($module_config_dir)) { - $files = glob($module_config_dir . '/*.' . FileStorage::getFileExtension()); - $this->assertTrue($files); - $config_dir = config_get_config_directory(); - // Get the filename of each config file. - foreach ($files as $file) { - $parts = explode('/', $file); - $filename = array_pop($parts); - if (file_exists($config_dir . '/' . $filename)) { - $files_exist = TRUE; - } - } - } - - return $this->assertFalse($files_exist, t('All config files defined by the @module module have been deleted from the live config directory.', array('@module' => $module))); + function assertNoModuleConfig($module) { + $names = DatabaseStorage::getNamesWithPrefix($module . '.'); + return $this->assertFalse($names, format_string('No configuration found for @module module.', array('@module' => $module))); } /** @@ -293,7 +278,7 @@ class EnableDisableTestCase extends ModuleTestCase { $this->assertText(t('hook_modules_enabled fired for @module', array('@module' => $module_to_enable))); $this->assertModules(array($module_to_enable), TRUE); $this->assertModuleTablesExist($module_to_enable); - $this->assertModuleConfigFilesExist($module_to_enable); + $this->assertModuleConfig($module_to_enable); $this->assertLogMessage('system', "%module module installed.", array('%module' => $module_to_enable), WATCHDOG_INFO); $this->assertLogMessage('system', "%module module enabled.", array('%module' => $module_to_enable), WATCHDOG_INFO); } @@ -374,7 +359,7 @@ class EnableDisableTestCase extends ModuleTestCase { // Check that the module's database tables still exist. $this->assertModuleTablesExist($module); // Check that the module's config files still exist. - $this->assertModuleConfigFilesExist($module); + $this->assertModuleConfig($module); // Uninstall the module. $edit = array(); @@ -396,7 +381,7 @@ class EnableDisableTestCase extends ModuleTestCase { // Check that the module's database tables no longer exist. $this->assertModuleTablesDoNotExist($module); // Check that the module's config files no longer exist. - $this->assertModuleConfigFilesDoNotExist($module); + $this->assertNoModuleConfig($module); } }