Commit f7113869 authored by sun's avatar sun

Fixed configuration file directory not setup for tests.

parent 9689b0be
......@@ -5180,7 +5180,7 @@ function drupal_page_set_cache() {
}
if ($cache->data['body']) {
if (variable_get('page_compression', TRUE) && extension_loaded('zlib')) {
if (config('system.performance')->get('page_compression') && extension_loaded('zlib')) {
$cache->data['body'] = gzencode($cache->data['body'], 9, FORCE_GZIP);
}
cache('page')->set($cache->cid, $cache->data, $cache->expire);
......
......@@ -16,7 +16,13 @@
function config_get_config_directory() {
global $config_directory_name;
return conf_path() . '/files/' . $config_directory_name;
if ($test_prefix = drupal_valid_test_ua()) {
$path = conf_path() . '/files/simpletest/config_' . $test_prefix;
}
else {
$path = conf_path() . '/files/' . $config_directory_name;
}
return $path;
}
/**
......
......@@ -111,10 +111,10 @@ public function verify($contentOnSuccess = FALSE) {
public function write($data) {
$signature = config_sign_data($data);
if (!file_put_contents($this->getFilePath(), $data)) {
throw new \Exception('Failed to write configuration file.');
throw new \Exception('Failed to write configuration file: ' . $this->getFilePath());
}
if (!file_put_contents($this->getFilePath() . '.sig', $signature)) {
throw new \Exception('Failed to write signature file.');
throw new \Exception('Failed to write signature file: ' . $this->getFilePath());
}
}
......
......@@ -1310,6 +1310,8 @@ protected function setUp() {
// Store necessary current values before switching to prefixed database.
$this->originalLanguage = $language;
$this->originalLanguageDefault = variable_get('language_default');
$this->originalConfigDirectory = $GLOBALS['config_directory_name'];
$this->originalConfigSignatureKey = $GLOBALS['config_signature_key'];
$this->originalFileDirectory = variable_get('file_public_path', conf_path() . '/files');
$this->originalProfile = drupal_get_profile();
$clean_url_original = variable_get('clean_url', 0);
......@@ -1346,6 +1348,14 @@ protected function setUp() {
file_prepare_directory($temp_files_directory, FILE_CREATE_DIRECTORY);
$this->generatedTestFiles = FALSE;
// Create and set a new configuration directory and signature key.
// The child site automatically adjusts the global $config_directory_name to
// a test-prefix-specific directory within the public files directory.
$GLOBALS['config_directory_name'] = 'simpletest/config_' . substr($this->databasePrefix, 10);
$this->configFileDirectory = $this->originalFileDirectory . '/' . $GLOBALS['config_directory_name'];
file_prepare_directory($this->configFileDirectory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
$GLOBALS['config_signature_key'] = drupal_hash_base64(drupal_random_bytes(55));
// Log fatal errors.
ini_set('log_errors', 1);
ini_set('error_log', $public_files_directory . '/error.log');
......@@ -1568,6 +1578,10 @@ protected function tearDown() {
// Rebuild caches.
$this->refreshVariables();
// Reset configuration globals.
$GLOBALS['config_directory_name'] = $this->originalConfigDirectory;
$GLOBALS['config_signature_key'] = $this->originalConfigSignatureKey;
// Reset language.
$language = $this->originalLanguage;
if ($this->originalLanguageDefault) {
......
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