diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 2b87fc2..40970c7 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -2406,46 +2406,39 @@ function drupal_get_bootstrap_phase() { * * @param Symfony\Component\DependencyInjection\Container $new_container * A new container instance to replace the current. - * @param bool $reset - * (optional) Internal use only. Whether to enforce a reset of the statically - * cached container. Pass NULL for $new_container to create a fresh Container - * in a subsequent call to this function. Used by tests. + * @param bool $rebuild + * (optional) Internal use only. Whether to build a new minimal container. * * @return Symfony\Component\DependencyInjection\Container * The instance of the Container used to set up and maintain object * instances. */ -function drupal_container(Container $new_container = NULL, $reset = FALSE) { +function drupal_container(Container $new_container = NULL, $rebuild = FALSE) { // We do not use drupal_static() here because we do not have a mechanism by // which to reinitialize the stored objects, so a drupal_static_reset() call // would leave Drupal in a nonfunctional state. static $container = NULL; - if (isset($new_container) || $reset) { - $container = $new_container; + if (isset($new_container) || $rebuild) { + $container = $rebuild ? NULL : $new_container; } - elseif (!isset($container)) { + if (!isset($container)) { // Return a ContainerBuilder instance with the bare essentials needed for any // full bootstrap regardless of whether there will be a DrupalKernel involved. // This will get merged with the full Kernel-built Container on normal page // requests. $container = new ContainerBuilder(); - // Register active configuration storage. - // @todo The active store and its options need to be configurable. - // Use either global $conf (recursion warning) or global $config, or a - // bootstrap configuration *file* to allow to set/override this very - // lowest of low level configuration. - $container->setParameter('config.storage.active.options', array( - 'Drupal\Core\Config\FileStorage' => array( - 'directory' => config_get_config_directory(CONFIG_ACTIVE_DIRECTORY), - ), - 'Drupal\Core\Config\CacheStorage' => array( - 'backend' => 'Drupal\Core\Cache\DatabaseBackend', - 'bin' => 'config', - ), - )); - $container->register('config.storage.active', 'Drupal\Core\Config\CachedFileStorage') - ->addArgument('%config.storage.active.options%'); + $container->register('config.storage.active', 'Drupal\Core\Config\FileStorage') + ->addArgument(config_get_config_directory()); + $container->register('config.storage.staging', 'Drupal\Core\Config\FileStorage') + ->addArgument(config_get_config_directory(CONFIG_STAGING_DIRECTORY)); + $container->register('config.cache') + ->setFactoryClass('Drupal\Core\Cache\CacheFactory') + ->setFactoryMethod('get') + ->addArgument('config'); + $container->register('config.storage', 'Drupal\Core\Config\CachedStorage') + ->addArgument(new Reference('config.storage.active')) + ->addArgument(new Reference('config.cache')); $container->register('config.subscriber.globalconf', 'Drupal\Core\EventSubscriber\ConfigGlobalOverrideSubscriber'); $container->register('dispatcher', 'Symfony\Component\EventDispatcher\EventDispatcher') @@ -2456,12 +2449,6 @@ function drupal_container(Container $new_container = NULL, $reset = FALSE) { ->addArgument(new Reference('config.storage.active')) ->addArgument(new Reference('dispatcher')); - // Register staging configuration storage. - $container->setParameter('config.storage.staging.options', array( - 'directory' => config_get_config_directory(CONFIG_STAGING_DIRECTORY), - )); - $container->register('config.storage.staging', 'Drupal\Core\Config\FileStorage') - ->addArgument('%config.storage.staging.options%'); } return $container; } diff --git a/core/includes/cache.inc b/core/includes/cache.inc index 73bb05f..ce53930 100644 --- a/core/includes/cache.inc +++ b/core/includes/cache.inc @@ -1,5 +1,7 @@ $config_dir)); - $target_storage = drupal_container()->get('config.storage.active'); + $source_storage = new FileStorage($config_dir); + $target_storage = drupal_container()->get('config.storage'); $null_storage = new NullStorage(); // Upon installation, only new config objects need to be created. @@ -45,7 +45,7 @@ function config_install_default_config($type, $name) { * @see Drupal\Core\Config\StorageInterface::listAll() */ function config_get_storage_names_with_prefix($prefix = '') { - return drupal_container()->get('config.storage.active')->listAll($prefix); + return drupal_container()->get('config.storage')->listAll($prefix); } /** @@ -137,7 +137,7 @@ function config_sync_changes(array $config_changes, StorageInterface $source_sto function config_import() { // Retrieve a list of differences between staging and the active store. $source_storage = drupal_container()->get('config.storage.staging'); - $target_storage = drupal_container()->get('config.storage.active'); + $target_storage = drupal_container()->get('config.storage'); $config_changes = config_sync_get_changes($source_storage, $target_storage); if (empty($config_changes)) { @@ -217,7 +217,7 @@ function config_import_invoke_owner(array $config_changes, StorageInterface $sou */ function config_export() { // Retrieve a list of differences between the active store and staging. - $source_storage = drupal_container()->get('config.storage.active'); + $source_storage = drupal_container()->get('config.storage'); $target_storage = drupal_container()->get('config.storage.staging'); $config_changes = config_sync_get_changes($source_storage, $target_storage); diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index dcfa049..c4c5ac7 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -302,9 +302,9 @@ function install_begin_request(&$install_state) { $container->register('dispatcher', 'Symfony\Component\EventDispatcher\EventDispatcher'); - $container->register('config.storage.active', 'Drupal\Core\Config\InstallStorage'); + $container->register('config.storage', 'Drupal\Core\Config\InstallStorage'); $container->register('config.factory', 'Drupal\Core\Config\ConfigFactory') - ->addArgument(new Reference('config.storage.active')) + ->addArgument(new Reference('config.storage')) ->addArgument(new Reference('dispatcher')); drupal_container($container); @@ -1092,8 +1092,8 @@ function install_settings_form_submit($form, &$form_state) { drupal_install_config_directories(); // We have valid configuration directories in settings.php. - // Reset the service container, so the config.storage.active service will use - // the actual active storage for installing configuration. + // Reset the service container, so the config.storage service will use the + // actual cached storage for installing configuration. drupal_container(NULL, TRUE); // Indicate that the settings file has been verified, and check the database diff --git a/core/includes/install.inc b/core/includes/install.inc index ba6069d..e7e2729 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -313,9 +313,10 @@ function install_verify_config_directory($type) { if (!isset($config_directories[$type])) { return FALSE; } - // config_get_config_directory() throws an exception when there is a prepared - // settings.php that defines $config_directories already and the directories - // do not exist yet. + // config_get_config_directory() throws an exception when the $type passed + // it doesn't exist yet in $config_directories. This can happen if there is + // a prepared settings.php that defines $config_directories already and the + // directories do not exist yet. try { $config_directory = config_get_config_directory($type); if (is_dir($config_directory) && is_writable($config_directory)) { diff --git a/core/includes/module.inc b/core/includes/module.inc index 7f3ad7b..bfa4268 100644 --- a/core/includes/module.inc +++ b/core/includes/module.inc @@ -616,7 +616,7 @@ function module_uninstall($module_list = array(), $uninstall_dependents = TRUE) $module_list = array_keys($module_list); } - $storage = drupal_container()->get('config.storage.active'); + $storage = drupal_container()->get('config.storage'); foreach ($module_list as $module) { // Uninstall the module. module_load_install($module); diff --git a/core/includes/update.inc b/core/includes/update.inc index 5582bb4..9dd8456 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -1056,7 +1056,7 @@ function update_variables_to_config($config_name, array $variable_map) { $module = strtok($config_name, '.'); // Load and set default configuration values. - $file = new FileStorage(array('directory' => drupal_get_path('module', $module) . '/config')); + $file = new FileStorage(drupal_get_path('module', $module) . '/config'); if (!$file->exists($config_name)) { throw new ConfigException("Default configuration file $config_name for $module extension not found but is required to exist."); } diff --git a/core/lib/Drupal/Core/Cache/CacheFactory.php b/core/lib/Drupal/Core/Cache/CacheFactory.php new file mode 100644 index 0000000..ca36824 --- /dev/null +++ b/core/lib/Drupal/Core/Cache/CacheFactory.php @@ -0,0 +1,11 @@ + 'Drupal\Core\Cache\DatabaseBackend', - 'bin' => 'config', - ); - $this->options = $options; - } - - /** - * Returns the instantiated Cache backend to use. - */ - protected function getBackend() { - if (!isset($this->storage)) { - $this->storage = new $this->options['backend']($this->options['bin']); - } - return $this->storage; - } - - /** - * Implements Drupal\Core\Config\StorageInterface::exists(). - */ - public function exists($name) { - return (bool) $this->getBackend()->get($name); - } - - /** - * Implements Drupal\Core\Config\StorageInterface::read(). - */ - public function read($name) { - if ($cache = $this->getBackend()->get($name)) { - // The cache backend supports primitive data types, but only an array - // represents valid config object data. - if (is_array($cache->data)) { - return $cache->data; - } - } - return FALSE; - } - - /** - * Implements Drupal\Core\Config\StorageInterface::write(). - */ - public function write($name, array $data) { - $this->getBackend()->set($name, $data, CacheBackendInterface::CACHE_PERMANENT, array('config' => array($name))); - return TRUE; - } - - /** - * Implements Drupal\Core\Config\StorageInterface::delete(). - */ - public function delete($name) { - $this->getBackend()->delete($name); - return TRUE; - } - - /** - * Implements Drupal\Core\Config\StorageInterface::rename(). - */ - public function rename($name, $new_name) { - $this->getBackend()->delete($name); - $this->getBackend()->delete($new_name); - return TRUE; - } - - /** - * Implements Drupal\Core\Config\StorageInterface::encode(). - */ - public static function encode($data) { - return serialize($data); - } - - /** - * Implements Drupal\Core\Config\StorageInterface::decode(). - * - * @throws ErrorException - * unserialize() triggers E_NOTICE if the string cannot be unserialized. - */ - public static function decode($raw) { - $data = @unserialize($raw); - return is_array($data) ? $data : FALSE; - } - - /** - * Implements Drupal\Core\Config\StorageInterface::listAll(). - * - * Not supported by CacheBackendInterface. - */ - public function listAll($prefix = '') { - return array(); - } -} diff --git a/core/lib/Drupal/Core/Config/CachedFileStorage.php b/core/lib/Drupal/Core/Config/CachedFileStorage.php deleted file mode 100644 index 0fc0cfe..0000000 --- a/core/lib/Drupal/Core/Config/CachedFileStorage.php +++ /dev/null @@ -1,134 +0,0 @@ -options = $options; - - $this->storages['file'] = new FileStorage($options['Drupal\Core\Config\FileStorage']); - - unset($options['Drupal\Core\Config\FileStorage']); - list($cache_class, $cache_options) = each($options); - $this->storages['cache'] = new $cache_class($cache_options); - } - - /** - * Implements Drupal\Core\Config\StorageInterface::exists(). - */ - public function exists($name) { - // A single filestat is faster than a complex cache lookup and possibly - // subsequent filestat. - return $this->storages['file']->exists($name); - } - - /** - * Implements Drupal\Core\Config\StorageInterface::read(). - */ - public function read($name) { - // Check the cache. - $data = $this->storages['cache']->read($name); - // If the cache returns no result, check the file storage. - if ($data === FALSE) { - $data = $this->storages['file']->read($name); - // @todo Should the config object be cached if it does not exist? - if ($data !== FALSE) { - $this->storages['cache']->write($name, $data); - } - } - return $data; - } - - /** - * Implements Drupal\Core\Config\StorageInterface::write(). - */ - public function write($name, array $data) { - $success = $this->storages['file']->write($name, $data); - $this->storages['cache']->delete($name); - return $success; - } - - /** - * Implements Drupal\Core\Config\StorageInterface::delete(). - */ - public function delete($name) { - $success = TRUE; - foreach ($this->storages as $storage) { - if (!$storage->delete($name)) { - $success = FALSE; - } - } - return $success; - } - - /** - * Implements Drupal\Core\Config\StorageInterface::rename(). - */ - public function rename($name, $new_name) { - $success = $this->storages['file']->rename($name, $new_name); - $this->storages['cache']->rename($name, $new_name); - return $success; - } - - /** - * Implements Drupal\Core\Config\StorageInterface::encode(). - * - * @todo Remove encode() from StorageInterface. - */ - public static function encode($data) { - return $this->storages['file']->encode($data); - } - - /** - * Implements Drupal\Core\Config\StorageInterface::decode(). - * - * @todo Remove decode() from StorageInterface. - */ - public static function decode($raw) { - return $this->storages['file']->decode($raw); - } - - /** - * Implements Drupal\Core\Config\StorageInterface::listAll(). - */ - public function listAll($prefix = '') { - return $this->storages['file']->listAll($prefix); - } -} diff --git a/core/lib/Drupal/Core/Config/CachedStorage.php b/core/lib/Drupal/Core/Config/CachedStorage.php new file mode 100644 index 0000000..f972776 --- /dev/null +++ b/core/lib/Drupal/Core/Config/CachedStorage.php @@ -0,0 +1,114 @@ +delegate = $delegate; + $this->cache = $cache; + } + + /** + * Implements Drupal\Core\Config\StorageInterface::exists(). + */ + public function exists($name) { + return $this->delegate->exists($name); + } + + /** + * Implements Drupal\Core\Config\StorageInterface::read(). + */ + public function read($name) { + if ($cache = $this->cache->get($name)) { + return $cache->data; + } + return $this->delegate->read($name); + } + + /** + * Implements Drupal\Core\Config\StorageInterface::write(). + */ + public function write($name, array $data) { + $this->cache->set($name, $data, CacheBackendInterface::CACHE_PERMANENT, array('config' => array($name))); + $this->delegate->write($name, $data); + return TRUE; + } + + /** + * Implements Drupal\Core\Config\StorageInterface::delete(). + */ + public function delete($name) { + $this->cache->delete($name); + $this->delegate->delete($name); + return TRUE; + } + + /** + * Implements Drupal\Core\Config\StorageInterface::rename(). + */ + public function rename($name, $new_name) { + $this->cache->delete($name); + $this->cache->delete($new_name); + $this->delegate->rename($name, $new_name); + return TRUE; + } + + /** + * Implements Drupal\Core\Config\StorageInterface::encode(). + */ + public static function encode($data) { + return serialize($data); + } + + /** + * Implements Drupal\Core\Config\StorageInterface::decode(). + * + * @throws ErrorException + * unserialize() triggers E_NOTICE if the string cannot be unserialized. + */ + public static function decode($raw) { + $data = @unserialize($raw); + return is_array($data) ? $data : FALSE; + } + + /** + * Implements Drupal\Core\Config\StorageInterface::listAll(). + * + * Not supported by CacheBackendInterface. + */ + public function listAll($prefix = '') { + return $this->delegate->listAll($prefix); + } +} diff --git a/core/lib/Drupal/Core/Config/DatabaseStorage.php b/core/lib/Drupal/Core/Config/DatabaseStorage.php deleted file mode 100644 index e4a1934..0000000 --- a/core/lib/Drupal/Core/Config/DatabaseStorage.php +++ /dev/null @@ -1,153 +0,0 @@ - 'default', - 'target' => 'default', - ); - $this->options = $options; - } - - /** - * Returns the database connection to use. - */ - protected function getConnection() { - return Database::getConnection($this->options['target'], $this->options['connection']); - } - - /** - * Implements Drupal\Core\Config\StorageInterface::exists(). - */ - public function exists($name) { - return (bool) $this->getConnection()->queryRange('SELECT 1 FROM {config} WHERE name = :name', 0, 1, array( - ':name' => $name, - ), $this->options)->fetchField(); - } - - /** - * Implements Drupal\Core\Config\StorageInterface::read(). - * - * @throws PDOException - * @throws Drupal\Core\Database\DatabaseExceptionWrapper - * Only thrown in case $this->options['throw_exception'] is TRUE. - */ - public function read($name) { - $data = FALSE; - // 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. - try { - $raw = $this->getConnection()->query('SELECT data FROM {config} WHERE name = :name', array(':name' => $name), $this->options)->fetchField(); - if ($raw !== FALSE) { - $data = $this->decode($raw); - } - } - catch (Exception $e) { - } - return $data; - } - - /** - * Implements Drupal\Core\Config\StorageInterface::write(). - * - * @throws PDOException - * - * @todo Ignore slave targets for data manipulation operations. - */ - public function write($name, array $data) { - $data = $this->encode($data); - $options = array('return' => Database::RETURN_AFFECTED) + $this->options; - return (bool) $this->getConnection()->merge('config', $options) - ->key(array('name' => $name)) - ->fields(array('data' => $data)) - ->execute(); - } - - /** - * Implements Drupal\Core\Config\StorageInterface::delete(). - * - * @throws PDOException - * - * @todo Ignore slave targets for data manipulation operations. - */ - public function delete($name) { - $options = array('return' => Database::RETURN_AFFECTED) + $this->options; - return (bool) $this->getConnection()->delete('config', $options) - ->condition('name', $name) - ->execute(); - } - - - /** - * Implements Drupal\Core\Config\StorageInterface::rename(). - * - * @throws PDOException - */ - public function rename($name, $new_name) { - $options = array('return' => Database::RETURN_AFFECTED) + $this->options; - return (bool) $this->getConnection()->update('config', $options) - ->fields(array('name' => $new_name)) - ->condition('name', $name) - ->execute(); - } - - /** - * Implements Drupal\Core\Config\StorageInterface::encode(). - */ - public static function encode($data) { - return serialize($data); - } - - /** - * Implements Drupal\Core\Config\StorageInterface::decode(). - * - * @throws ErrorException - * unserialize() triggers E_NOTICE if the string cannot be unserialized. - */ - public static function decode($raw) { - $data = @unserialize($raw); - return is_array($data) ? $data : FALSE; - } - - /** - * Implements Drupal\Core\Config\StorageInterface::listAll(). - * - * @throws PDOException - * @throws Drupal\Core\Database\DatabaseExceptionWrapper - * Only thrown in case $this->options['throw_exception'] is TRUE. - */ - public function listAll($prefix = '') { - return $this->getConnection()->query('SELECT name FROM {config} WHERE name LIKE :name', array( - ':name' => db_like($prefix) . '%', - ), $this->options)->fetchCol(); - } -} diff --git a/core/lib/Drupal/Core/Config/FileStorage.php b/core/lib/Drupal/Core/Config/FileStorage.php index cbad07f..716373e 100644 --- a/core/lib/Drupal/Core/Config/FileStorage.php +++ b/core/lib/Drupal/Core/Config/FileStorage.php @@ -15,22 +15,17 @@ class FileStorage implements StorageInterface { /** - * Configuration options for this storage controller. + * The filesystem path for configuration objects. * - * - directory: The filesystem path for configuration objects. - * - * @var array + * @var string */ - protected $options; + protected $directory = ''; /** * Implements Drupal\Core\Config\StorageInterface::__construct(). */ - public function __construct(array $options = array()) { - if (!isset($options['directory'])) { - $options['directory'] = config_get_config_directory(CONFIG_ACTIVE_DIRECTORY); - } - $this->options = $options; + public function __construct($directory) { + $this->directory = $directory; } /** @@ -40,7 +35,7 @@ public function __construct(array $options = array()) { * The path to the configuration file. */ public function getFilePath($name) { - return $this->options['directory'] . '/' . $name . '.' . self::getFileExtension(); + return $this->directory . '/' . $name . '.' . self::getFileExtension(); } /** @@ -54,7 +49,10 @@ public static function getFileExtension() { } /** - * Implements Drupal\Core\Config\StorageInterface::exists(). + * Returns whether the configuration file exists. + * + * @return bool + * TRUE if the configuration file exists, FALSE otherwise. */ public function exists($name) { return file_exists($this->getFilePath($name)); @@ -96,8 +94,8 @@ public function write($name, array $data) { */ public function delete($name) { if (!$this->exists($name)) { - if (!file_exists($this->options['directory'])) { - throw new StorageException($this->options['directory'] . '/ not found.'); + if (!file_exists($this->directory)) { + throw new StorageException($this->directory . '/ not found.'); } return FALSE; } @@ -146,11 +144,11 @@ public static function decode($raw) { public function listAll($prefix = '') { // glob() silently ignores the error of a non-existing search directory, // even with the GLOB_ERR flag. - if (!file_exists($this->options['directory'])) { - throw new StorageException($this->options['directory'] . '/ not found.'); + if (!file_exists($this->directory)) { + throw new StorageException($this->directory . '/ not found.'); } $extension = '.' . self::getFileExtension(); - $files = glob($this->options['directory'] . '/' . $prefix . '*' . $extension); + $files = glob($this->directory . '/' . $prefix . '*' . $extension); $clean_name = function ($value) use ($extension) { return basename($value, $extension); }; diff --git a/core/lib/Drupal/Core/Config/InstallStorage.php b/core/lib/Drupal/Core/Config/InstallStorage.php index b2ee894..f232f63 100644 --- a/core/lib/Drupal/Core/Config/InstallStorage.php +++ b/core/lib/Drupal/Core/Config/InstallStorage.php @@ -15,19 +15,9 @@ class InstallStorage extends FileStorage { /** - * Configuration options for this storage controller. - * - * @var array - */ - protected $options; - - /** - * Implements Drupal\Core\Config\StorageInterface::__construct(). + * Overrides Drupal\Core\Config\FileStorage::__construct(). */ - public function __construct(array $options = array()) { - // Intentionally not calling FileStorage's constructor, since that calls - // into config_get_config_directory(), which is not functional yet. - $this->options = $options; + public function __construct() { } /** @@ -73,7 +63,7 @@ public function getFilePath($name) { * @throws Drupal\Core\Config\StorageException */ public function write($name, array $data) { - throw new StorageException('Write operations are not allowed.'); + throw new StorageException('Write operation is not allowed during install.'); } /** @@ -82,7 +72,7 @@ public function write($name, array $data) { * @throws Drupal\Core\Config\StorageException */ public function delete($name) { - throw new StorageException('Write operations are not allowed.'); + throw new StorageException('Delete operation is not allowed during install.'); } /** @@ -91,7 +81,7 @@ public function delete($name) { * @throws Drupal\Core\Config\StorageException */ public function rename($name, $new_name) { - throw new StorageException('Write operations are not allowed.'); + throw new StorageException('Rename operation is not allowed during install.'); } /** @@ -100,6 +90,6 @@ public function rename($name, $new_name) { * @throws Drupal\Core\Config\StorageException */ public function listAll($prefix = '') { - throw new StorageException('List operation is not supported.'); + throw new StorageException('List operation is not allowed during install.'); } } diff --git a/core/lib/Drupal/Core/Config/NullStorage.php b/core/lib/Drupal/Core/Config/NullStorage.php index aa81b73..36cdc29 100644 --- a/core/lib/Drupal/Core/Config/NullStorage.php +++ b/core/lib/Drupal/Core/Config/NullStorage.php @@ -22,11 +22,6 @@ * This also can be used for testing purposes. */ class NullStorage implements StorageInterface { - /** - * Implements Drupal\Core\Config\StorageInterface::__construct(). - */ - public function __construct(array $options = array()) { - } /** * Implements Drupal\Core\Config\StorageInterface::exists(). diff --git a/core/lib/Drupal/Core/Config/StorageInterface.php b/core/lib/Drupal/Core/Config/StorageInterface.php index 688ae46..9a2caa7 100644 --- a/core/lib/Drupal/Core/Config/StorageInterface.php +++ b/core/lib/Drupal/Core/Config/StorageInterface.php @@ -16,15 +16,6 @@ interface StorageInterface { /** - * Constructs the storage controller. - * - * @param array $options - * An associative array containing configuration options specific to the - * storage controller. - */ - public function __construct(array $options = array()); - - /** * Returns whether a configuration object exists. * * @param string $name diff --git a/core/modules/config/lib/Drupal/config/ConfigStorageController.php b/core/modules/config/lib/Drupal/config/ConfigStorageController.php index 722ae46..f806532 100644 --- a/core/modules/config/lib/Drupal/config/ConfigStorageController.php +++ b/core/modules/config/lib/Drupal/config/ConfigStorageController.php @@ -155,7 +155,7 @@ protected function buildQuery($ids, $revision_id = FALSE) { // Load all of the configuration entities. if ($ids === NULL) { - $names = drupal_container()->get('config.storage.active')->listAll($prefix); + $names = drupal_container()->get('config.storage')->listAll($prefix); $result = array(); foreach ($names as $name) { $config = config($name); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigCRUDTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigCRUDTest.php index 3a66d57..9eea495 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigCRUDTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigCRUDTest.php @@ -25,7 +25,7 @@ public static function getInfo() { * Tests CRUD operations. */ function testCRUD() { - $storage = $this->container->get('config.storage.active'); + $storage = $this->container->get('config.storage'); $name = 'config_test.crud'; $config = config($name); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigFileContentTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigFileContentTest.php index 4a82d0b..f3d91b0 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigFileContentTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigFileContentTest.php @@ -26,7 +26,7 @@ public static function getInfo() { * Tests setting, writing, and reading of a configuration setting. */ function testReadWriteConfig() { - $storage = $this->container->get('config.storage.active'); + $storage = $this->container->get('config.storage'); $name = 'foo.bar'; $key = 'foo'; @@ -62,8 +62,8 @@ function testReadWriteConfig() { $this->assertEqual($config->get(), array(), t('New config object is empty.')); // Verify nothing was saved. - $db_data = $storage->read($name); - $this->assertIdentical($db_data, FALSE); + $data = $storage->read($name); + $this->assertIdentical($data, FALSE); // Add a top level value $config = config($name); @@ -89,8 +89,8 @@ function testReadWriteConfig() { $config->save(); // Verify the database entry exists. - $db_data = $storage->read($name); - $this->assertTrue($db_data); + $data = $storage->read($name); + $this->assertTrue($data); // Read top level value $config = config($name); @@ -147,8 +147,8 @@ function testReadWriteConfig() { $config->set($key, $value)->save(); // Verify the database entry exists from a chained save. - $db_data = $storage->read($chained_name); - $this->assertEqual($db_data, $config->get()); + $data = $storage->read($chained_name); + $this->assertEqual($data, $config->get()); // Get file listing for all files starting with 'foo'. Should return // two elements. @@ -175,8 +175,8 @@ function testReadWriteConfig() { $config->delete(); // Verify the database entry no longer exists. - $db_data = $storage->read($name); - $this->assertIdentical($db_data, FALSE); + $data = $storage->read($name); + $this->assertIdentical($data, FALSE); } /** @@ -200,7 +200,7 @@ function testSerialization() { ); // Encode and write, and reload and decode the configuration data. - $filestorage = new FileStorage(); + $filestorage = new FileStorage(config_get_config_directory()); $filestorage->write($name, $config_data); $config_parsed = $filestorage->read($name); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php index 8ad26f0..9316962 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php @@ -62,7 +62,7 @@ function testNoImport() { function testDeleted() { $name = 'config_test.system'; $dynamic_name = 'config_test.dynamic.default'; - $storage = $this->container->get('config.storage.active'); + $storage = $this->container->get('config.storage'); $staging = $this->container->get('config.storage.staging'); // Verify the default configuration values exist. @@ -108,7 +108,7 @@ function testDeleted() { function testNew() { $name = 'config_test.new'; $dynamic_name = 'config_test.dynamic.new'; - $storage = $this->container->get('config.storage.active'); + $storage = $this->container->get('config.storage'); $staging = $this->container->get('config.storage.staging'); // Export. @@ -164,7 +164,7 @@ function testNew() { function testUpdated() { $name = 'config_test.system'; $dynamic_name = 'config_test.dynamic.default'; - $storage = $this->container->get('config.storage.active'); + $storage = $this->container->get('config.storage'); $staging = $this->container->get('config.storage.staging'); // Export. diff --git a/core/modules/config/lib/Drupal/config/Tests/Storage/DatabaseStorageTest.php b/core/modules/config/lib/Drupal/config/Tests/Storage/DatabaseStorageTest.php deleted file mode 100644 index 185921f..0000000 --- a/core/modules/config/lib/Drupal/config/Tests/Storage/DatabaseStorageTest.php +++ /dev/null @@ -1,72 +0,0 @@ - 'DatabaseStorage controller operations', - 'description' => 'Tests DatabaseStorage controller operations.', - 'group' => 'Configuration', - ); - } - - function setUp() { - parent::setUp(); - - $schema['config'] = array( - 'description' => 'Default active store for the configuration system.', - 'fields' => array( - 'name' => array( - 'description' => 'The identifier for the configuration entry, such as module.example (the name of the file, minus the file extension).', - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'default' => '', - ), - 'data' => array( - 'description' => 'The raw data for this configuration entry.', - 'type' => 'blob', - 'not null' => TRUE, - 'size' => 'big', - 'translatable' => TRUE, - ), - ), - 'primary key' => array('name'), - ); - db_create_table('config', $schema['config']); - - $this->storage = new DatabaseStorage(); - $this->invalidStorage = new DatabaseStorage(array('connection' => 'invalid')); - - // ::listAll() verifications require other configuration data to exist. - $this->storage->write('system.performance', array()); - } - - protected function read($name) { - $data = db_query('SELECT data FROM {config} WHERE name = :name', array(':name' => $name))->fetchField(); - return unserialize($data); - } - - protected function insert($name, $data) { - db_insert('config')->fields(array('name' => $name, 'data' => $data))->execute(); - } - - protected function update($name, $data) { - db_update('config')->fields(array('data' => $data))->condition('name', $name)->execute(); - } - - protected function delete($name) { - db_delete('config')->condition('name', $name)->execute(); - } -} diff --git a/core/modules/config/lib/Drupal/config/Tests/Storage/FileStorageTest.php b/core/modules/config/lib/Drupal/config/Tests/Storage/FileStorageTest.php index 0fd2ba4..61b3906 100644 --- a/core/modules/config/lib/Drupal/config/Tests/Storage/FileStorageTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/Storage/FileStorageTest.php @@ -24,8 +24,8 @@ public static function getInfo() { function setUp() { parent::setUp(); - $this->storage = new FileStorage(); - $this->invalidStorage = new FileStorage(array('directory' => $this->configDirectories[CONFIG_ACTIVE_DIRECTORY] . '/nonexisting')); + $this->storage = new FileStorage(config_get_config_directory()); + $this->invalidStorage = new FileStorage($this->configDirectories[CONFIG_ACTIVE_DIRECTORY] . '/nonexisting'); // FileStorage::listAll() requires other configuration data to exist. $this->storage->write('system.performance', config('system.performance')->get()); diff --git a/core/modules/entity/lib/Drupal/entity/Entity.php b/core/modules/entity/lib/Drupal/entity/Entity.php index 9701d28..dae1760 100644 --- a/core/modules/entity/lib/Drupal/entity/Entity.php +++ b/core/modules/entity/lib/Drupal/entity/Entity.php @@ -287,5 +287,4 @@ public function isCurrentRevision($new_value = NULL) { } return $return; } - } diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 210b058..e48efd0 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -674,6 +674,7 @@ protected function setUp() { // Symfony\Component\HttpKernel\handle(), this kernel needs manual booting // as it is not used to handle a request. $this->kernel->boot(); + $this->container = drupal_container(); // Reset/rebuild all data structures after enabling the modules. $this->resetAll(); diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleTestBase.php index 1698737..4a728f3 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleTestBase.php @@ -8,7 +8,6 @@ namespace Drupal\system\Tests\Module; use Drupal\Core\Database\Database; -use Drupal\Core\Config\DatabaseStorage; use Drupal\Core\Config\FileStorage; use Drupal\simpletest\WebTestBase; @@ -99,7 +98,7 @@ function assertModuleConfig($module) { if (!is_dir($module_config_dir)) { return; } - $module_file_storage = new FileStorage(array('directory' => $module_config_dir)); + $module_file_storage = new FileStorage($module_config_dir); $names = $module_file_storage->listAll(); // Verify that the config directory is not empty. diff --git a/core/modules/system/system.install b/core/modules/system/system.install index dc8821f..2edca25 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -1550,8 +1550,8 @@ function system_update_8002() { * Creates {cache_config} cache table for the new configuration system. */ function system_update_8003() { - $schema['cache'] = array( - 'description' => 'Generic cache table for caching things not separated out into their own tables. Contributed modules may also use this to store cached items.', + $cache_update = array( + 'description' => 'Cache table for configuration data.', 'fields' => array( 'cid' => array( 'description' => 'Primary Key: Unique cache ID.', @@ -1603,7 +1603,7 @@ function system_update_8003() { ), 'primary key' => array('cid'), ); - db_create_table('cache_config', $schema['cache']); + db_create_table('cache_config', $cache_update); } /**