Commit 7240b39b authored by catch's avatar catch

Issue #1887750 by Berdir, alexpott: Use path relative to DRUPAL_ROOT in configuration directories.

parent 14e5cdb0
......@@ -418,18 +418,9 @@ function config_get_config_directory($type = CONFIG_ACTIVE_DIRECTORY) {
global $config_directories;
if (!empty($config_directories[$type])) {
// Allow a configuration directory path to be outside of webroot.
if (empty($config_directories[$type]['absolute'])) {
$path = conf_path() . '/files/' . $config_directories[$type]['path'];
}
else {
$path = $config_directories[$type]['path'];
}
return $config_directories[$type];
}
else {
throw new Exception(format_string('The configuration directory type %type does not exist.', array('%type' => $type)));
}
return $path;
throw new Exception(format_string('The configuration directory type %type does not exist.', array('%type' => $type)));
}
/**
......@@ -2293,7 +2284,7 @@ function _drupal_load_test_overrides($test_prefix) {
$path_prefix = 'simpletest/' . substr($test_prefix, 10);
$config_directories = array();
foreach (array(CONFIG_ACTIVE_DIRECTORY, CONFIG_STAGING_DIRECTORY) as $type) {
$config_directories[$type] = array('path' => $path_prefix . '/config_' . $type);
$config_directories[$type] = conf_path() . '/files/' . $path_prefix . '/config_' . $type;
}
// Check for and load a settings.php file in the simpletest files directory.
......
......@@ -177,24 +177,20 @@ function drupal_get_database_types() {
* and comment properties.
* @code
* $settings['config_directories'] = array(
* CONFIG_ACTIVE_DIRECTORY => array(
* 'path' => (object) array(
* 'value' => 'config__hash/active'
* 'required' => TRUE,
* ),
* CONFIG_ACTIVE_DIRECTORY => (object) array(
* 'value' => 'config_hash/active'
* 'required' => TRUE,
* ),
* CONFIG_STAGING_DIRECTORY => array(
* 'path' => (object) array(
* 'value' => 'config_hash/staging',
* 'required' => TRUE,
* ),
* CONFIG_STAGING_DIRECTORY => (object) array(
* 'value' => 'config_hash/staging',
* 'required' => TRUE,
* ),
* );
* @endcode
* gets dumped as:
* @code
* $config_directories['active']['path'] = 'config__hash/active';
* $config_directories['staging']['path'] = 'config__hash/staging'
* $config_directories['active'] = 'config_hash/active';
* $config_directories['staging'] = 'config_hash/staging'
* @endcode
*/
function drupal_rewrite_settings($settings = array(), $settings_file = NULL) {
......@@ -452,17 +448,13 @@ function drupal_install_config_directories($mode = NULL) {
if (empty($config_directories)) {
$config_directories_hash = Crypt::randomStringHashed(55);
$settings['config_directories'] = array(
CONFIG_ACTIVE_DIRECTORY => array(
'path' => (object) array(
'value' => 'config_' . $config_directories_hash . '/active',
'required' => TRUE,
),
CONFIG_ACTIVE_DIRECTORY => (object) array(
'value' => conf_path() . '/files/config_' . $config_directories_hash . '/active',
'required' => TRUE,
),
CONFIG_STAGING_DIRECTORY => array(
'path' => (object) array(
'value' => 'config_' . $config_directories_hash . '/staging',
'required' => TRUE,
),
CONFIG_STAGING_DIRECTORY => (object) array(
'value' => conf_path() . '/files/config_' . $config_directories_hash . '/staging',
'required' => TRUE,
),
);
// Rewrite settings.php, which also sets the value as global variable.
......
......@@ -1012,14 +1012,14 @@ protected function prepareConfigDirectories() {
include_once DRUPAL_ROOT . '/core/includes/install.inc';
foreach (array(CONFIG_ACTIVE_DIRECTORY, CONFIG_STAGING_DIRECTORY) as $type) {
// Assign the relative path to the global variable.
$path = 'simpletest/' . substr($this->databasePrefix, 10) . '/config_' . $type;
$GLOBALS['config_directories'][$type]['path'] = $path;
$path = conf_path() . '/files/simpletest/' . substr($this->databasePrefix, 10) . '/config_' . $type;
$GLOBALS['config_directories'][$type] = $path;
// Ensure the directory can be created and is writeable.
if (!install_ensure_config_directory($type)) {
return FALSE;
}
// Provide the already resolved path for tests.
$this->configDirectories[$type] = $this->originalFileDirectory . '/' . $path;
$this->configDirectories[$type] = $path;
}
}
......
......@@ -108,9 +108,8 @@ protected function setUp() {
// Reload config directories.
include $this->public_files_directory . '/settings.php';
$prefix = substr($this->public_files_directory, strlen(conf_path() . '/files/'));
foreach ($config_directories as $type => $data) {
$GLOBALS['config_directories'][$type]['path'] = $prefix . '/files/' . $data['path'];
foreach ($config_directories as $type => $path) {
$GLOBALS['config_directories'][$type] = $path;
}
$this->rebuildContainer();
......
......@@ -82,9 +82,8 @@ protected function setUp() {
$this->drupalPostForm(NULL, array(), 'Save and continue');
// Reload config directories.
include $this->public_files_directory . '/settings.php';
$prefix = substr($this->public_files_directory, strlen(conf_path() . '/files/'));
foreach ($config_directories as $type => $data) {
$GLOBALS['config_directories'][$type]['path'] = $prefix . '/files/' . $data['path'];
foreach ($config_directories as $type => $path) {
$GLOBALS['config_directories'][$type] = $path;
}
$this->rebuildContainer();
......
......@@ -246,14 +246,8 @@
* Example:
* @code
* $config_directories = array(
* CONFIG_ACTIVE_DIRECTORY => array(
* 'path' => '/some/directory/outside/webroot',
* 'absolute' => TRUE,
* ),
* CONFIG_STAGING_DIRECTORY => array(
* 'path' => '/another/directory/outside/webroot',
* 'absolute' => TRUE,
* ),
* CONFIG_ACTIVE_DIRECTORY => '/some/directory/outside/webroot',
* CONFIG_STAGING_DIRECTORY => '/another/directory/outside/webroot',
* );
* @endcode
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment