Commit c74a333a authored by young hahn's avatar young hahn
Browse files

#656600 by mrfelton: Allow hardcoded settings.php global conf variables to retain their values.

parent a244d12f
...@@ -19,6 +19,8 @@ function strongarm_get_culprits() { ...@@ -19,6 +19,8 @@ function strongarm_get_culprits() {
* Variable management strongarm form. * Variable management strongarm form.
*/ */
function strongarm_admin_form($form_state) { function strongarm_admin_form($form_state) {
global $conf;
ctools_include('export'); ctools_include('export');
$vars = ctools_export_load_object('variable'); $vars = ctools_export_load_object('variable');
ksort($vars); ksort($vars);
...@@ -26,7 +28,22 @@ function strongarm_admin_form($form_state) { ...@@ -26,7 +28,22 @@ function strongarm_admin_form($form_state) {
foreach ($vars as $name => $variable) { foreach ($vars as $name => $variable) {
if ($variable->export_type & EXPORT_IN_CODE) { if ($variable->export_type & EXPORT_IN_CODE) {
$default = ctools_get_default_object('variable', $name); $default = ctools_get_default_object('variable', $name);
if (($variable->export_type & EXPORT_IN_DATABASE) && ($variable->value != $default->value)) {
// If variable value does not match global $conf, this value has been
// hardcoded (e.g. in settings.php) and has been allowed to pass
// through. It cannot be reverted.
if ($conf[$name] !== $variable->value) {
$storage = t('Hardcoded');
$hardcoded = TRUE;
}
else {
$storage = ($variable->value == $default->value) ? t('Default') : t('Overridden');
$hardcoded = FALSE;
}
// If the variable is in the database and differs from its code value,
// allow administrator to revert its value.
if (!$hardcoded && ($variable->export_type & EXPORT_IN_DATABASE) && ($variable->value != $default->value)) {
$form['revert']['#tree'] = TRUE; $form['revert']['#tree'] = TRUE;
$form['revert'][$name] = array('#type' => 'checkbox'); $form['revert'][$name] = array('#type' => 'checkbox');
} }
...@@ -36,7 +53,7 @@ function strongarm_admin_form($form_state) { ...@@ -36,7 +53,7 @@ function strongarm_admin_form($form_state) {
); );
$form['storage'][$name] = array( $form['storage'][$name] = array(
'#type' => 'markup', '#type' => 'markup',
'#value' => ($variable->value == $default->value) ? t('Default') : t('Overridden'), '#value' => $storage,
); );
$form['value'][$name] = array( $form['value'][$name] = array(
'#type' => 'markup', '#type' => 'markup',
......
...@@ -46,7 +46,7 @@ function strongarm_set_conf($reset = FALSE) { ...@@ -46,7 +46,7 @@ function strongarm_set_conf($reset = FALSE) {
cache_set('strongarm', $var_conf); cache_set('strongarm', $var_conf);
} }
global $conf; global $conf;
$conf = $var_conf; $conf = array_merge($var_conf, $conf);
} }
/** /**
......
Supports Markdown
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