Commit c1c2ceab authored by gdd's avatar gdd
Browse files

Fixing problems related to corepocalypse merge

parent 4eb660a5
......@@ -236,6 +236,8 @@
*/
const DRUPAL_PHP_FUNCTION_PATTERN = '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*';
require_once DRUPAL_ROOT . '/includes/config.inc';
/**
* Provides a caching wrapper to be used in place of large array structures.
*
......@@ -751,7 +753,7 @@ function drupal_settings_initialize() {
global $base_url, $base_path, $base_root;
// Export the following settings.php variables to the global namespace
global $databases, $cookie_domain, $conf, $installed_profile, $update_free_access, $db_url, $db_prefix, $drupal_hash_salt, $is_https, $base_secure_url, $base_insecure_url;
global $databases, $cookie_domain, $conf, $installed_profile, $update_free_access, $db_url, $db_prefix, $drupal_hash_salt, $is_https, $base_secure_url, $base_insecure_url, $drupal_config_directory_name, $drupal_config_key;
$conf = array();
if (file_exists(DRUPAL_ROOT . '/' . conf_path() . '/settings.php')) {
......
File mode changed from 100644 to 100755
......@@ -992,7 +992,26 @@ function install_settings_form_submit($form, &$form_state) {
'value' => drupal_hash_base64(drupal_random_bytes(55)),
'required' => TRUE,
);
$settings['drupal_config_key'] = array(
'value' => drupal_hash_base64(drupal_random_bytes(55)),
'required' => TRUE,
);
// This duplicates drupal_get_token() because that function can't work yet.
// Wondering if it makes sense to move this later in the process, but its
// nice having all the settings stuff here.
$settings['drupal_config_directory_name'] = array(
'value' => 'config_' . drupal_hmac_base64('', session_id() . $settings['drupal_config_key']['value'] . $settings['drupal_hash_salt']['value']),
'required' => TRUE,
);
drupal_rewrite_settings($settings);
// Actually create the config directory named above.
$config_path = conf_path() . '/files/' . $settings['drupal_config_directory_name']['value'];
if (!file_prepare_directory($config_path, FILE_CREATE_DIRECTORY)) {
// How best to handle errors here?
};
// Indicate that the settings file has been verified, and check the database
// for the last completed task, now that we have a valid connection. This
// last step is important since we want to trigger an error if the new
......
......@@ -731,6 +731,7 @@ function drupal_install_system() {
))
->execute();
system_rebuild_module_data();
config_install_default_config('system');
}
/**
......
......@@ -437,6 +437,9 @@ 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/
config_install_default_config($module);
// If the module has no current updates, but has some that were
// previously removed, set the version to the value of
// hook_update_last_removed().
......
......@@ -1640,8 +1640,9 @@ function system_logging_settings() {
* @ingroup forms
* @see system_settings_form()
*/
function system_performance_settings() {
function system_performance_settings($form, &$form_state) {
drupal_add_js(drupal_get_path('module', 'system') . '/system.js');
$config = config('system.performance');
$form['clear_cache'] = array(
'#type' => 'fieldset',
......@@ -1654,16 +1655,47 @@ function system_performance_settings() {
'#submit' => array('system_clear_cache_submit'),
);
// TODO: This is a complete hack. The idea is - we need to stash some state
// with this form, so that when it comes time to save, we can go from a key
// in $form_state['values'] to that state. I started trying to put this state
// with each form element, but I have NFI how to get to a form element from
// a key in $form_state['values'].
$form_state['config'] = array(
'cache' => array(
'name' => 'system.performance',
'path' => 'caching.cache',
),
'cache_lifetime' => array(
'name' => 'system.performance',
'path' => 'caching.cache_lifetime',
),
'page_cache_maximum_age' => array(
'name' => 'system.performance',
'path' => 'caching.page_cache_maximum_age',
),
'page_compression' => array(
'name' => 'system.performance',
'path' => 'bandwidth_optimization.page_compression',
),
'preprocess_css' => array(
'name' => 'system.performance',
'path' => 'bandwidth_optimization.preprocess_css',
),
'preprocess_js' => array(
'name' => 'system.performance',
'path' => 'bandwidth_optimization.preprocess_js',
),
);
$form['caching'] = array(
'#type' => 'fieldset',
'#title' => t('Caching'),
);
$cache = variable_get('cache', 0);
$form['caching']['cache'] = array(
'#type' => 'checkbox',
'#title' => t('Cache pages for anonymous users'),
'#default_value' => $cache,
'#default_value' => $config->get('caching.cache'),
'#weight' => -2,
);
$period = drupal_map_assoc(array(0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400), 'format_interval');
......@@ -1671,16 +1703,16 @@ function system_performance_settings() {
$form['caching']['cache_lifetime'] = array(
'#type' => 'select',
'#title' => t('Minimum cache lifetime'),
'#default_value' => variable_get('cache_lifetime', 0),
'#default_value' => $config->get('caching.cache_lifetime'),
'#options' => $period,
'#description' => t('Cached pages will not be re-created until at least this much time has elapsed.')
'#description' => t('Cached pages will not be re-created until at least this much time has elapsed.'),
);
$form['caching']['page_cache_maximum_age'] = array(
'#type' => 'select',
'#title' => t('Expiration of cached pages'),
'#default_value' => variable_get('page_cache_maximum_age', 0),
'#default_value' => $config->get('caching.page_cache_maximum_age'),
'#options' => $period,
'#description' => t('The maximum time an external cache can use an old version of a page.')
'#description' => t('The maximum time an external cache can use an old version of a page.'),
);
$directory = 'public://';
......@@ -1697,24 +1729,24 @@ function system_performance_settings() {
'#description' => t('External resources can be optimized automatically, which can reduce both the size and number of requests made to your website.') . $disabled_message,
);
$js_hide = $cache ? '' : ' class="js-hide"';
$js_hide = $config->get('caching') ? '' : ' class="js-hide"';
$form['bandwidth_optimization']['page_compression'] = array(
'#type' => 'checkbox',
'#title' => t('Compress cached pages.'),
'#default_value' => variable_get('page_compression', TRUE),
'#default_value' => $config->get('bandwidth_optimization.page_compression'),
'#prefix' => '<div id="page-compression-wrapper"' . $js_hide . '>',
'#suffix' => '</div>',
);
$form['bandwidth_optimization']['preprocess_css'] = array(
'#type' => 'checkbox',
'#title' => t('Aggregate and compress CSS files.'),
'#default_value' => intval(variable_get('preprocess_css', 0) && $is_writable),
'#default_value' => $config->get('bandwidth_optimization.preprocess_css'),
'#disabled' => $disabled,
);
$form['bandwidth_optimization']['preprocess_js'] = array(
'#type' => 'checkbox',
'#title' => t('Aggregate JavaScript files.'),
'#default_value' => intval(variable_get('preprocess_js', 0) && $is_writable),
'#default_value' => $config->get('bandwidth_optimization.preprocess_js'),
'#disabled' => $disabled,
);
......
......@@ -690,6 +690,28 @@ function system_schema() {
$schema['cache_path'] = $schema['cache'];
$schema['cache_path']['description'] = 'Cache table for path alias lookup.';
$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 .json.php).',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'data' => array(
'description' => 'The raw JSON data for this configuration entry.',
'type' => 'blob',
'not null' => TRUE,
'size' => 'big',
'translatable' => TRUE,
),
),
'primary key' => array('name'),
);
$schema['date_format_type'] = array(
'description' => 'Stores configured date format types.',
'fields' => array(
......
......@@ -2773,12 +2773,27 @@ function system_settings_form_submit($form, &$form_state) {
// Exclude unnecessary elements.
form_state_values_clean($form_state);
$config_objects = array();
foreach ($form_state['values'] as $key => $value) {
if (isset($form_state['config'][$key])) {
$config_name = $form_state['config'][$key]['name'];
$config_key = $form_state['config'][$key]['path'];
if (empty($config_objects[$config_name])) {
$config_objects[$config_name] = config($config_name);
}
if (!empty($config_objects[$config_name])) {
$config_objects[$config_name]->set($config_key, $value);
continue;
}
}
if (is_array($value) && isset($form_state['values']['array_filter'])) {
$value = array_keys(array_filter($value));
}
variable_set($key, $value);
}
foreach ($config_objects as $config) {
$config->save();
}
drupal_set_message(t('The configuration options have been saved.'));
}
......
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