diff --git a/core/includes/update.inc b/core/includes/update.inc index 343d980..e277660 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -1044,6 +1044,9 @@ function update_variable_del($name) { * @endcode * This would migrate the value contained in variable name 'old_variable' into * the data key 'new_config.sub_key' of the configuration object $config_name. + * @param string $default_config_name + * The name of the configuration object to copy data from if $config_name + * does not yet exist. */ function update_variables_to_config($config_name, array $variable_map, $default_config_name = NULL) { // Build the new configuration object. @@ -1057,16 +1060,14 @@ function update_variables_to_config($config_name, array $variable_map, $default_ // Load and set default configuration values. $file = new FileStorage(drupal_get_path('module', $module) . '/config'); - if (!$file->exists($config_name)) { - if ($default_config_name && $file->exists($default_config_name)) { - $default_data = $file->read($default_config_name); - } - else { - throw new ConfigException("Default configuration file $config_name for $module extension not found but is required to exist."); - } + if ($file->exists($config_name)) { + $default_data = $file->read($config_name); + } + elseif ($default_config_name && $file->exists($default_config_name)) { + $default_data = $file->read($default_config_name); } else { - $default_data = $file->read($config_name); + throw new ConfigException("Default configuration file $config_name for $module extension not found but is required to exist."); } // Merge any possibly existing original data into default values. // Only relevant when being called repetitively on the same config object. diff --git a/core/modules/comment/comment.install b/core/modules/comment/comment.install index bb0ddc2..068e53c 100644 --- a/core/modules/comment/comment.install +++ b/core/modules/comment/comment.install @@ -13,19 +13,11 @@ function comment_uninstall() { field_delete_field('comment_body'); // Remove variables. - config('comment.settings')->clear('comment_block_count'); + config('comment.settings')->delete(); $node_types = array_keys(node_type_get_types()); foreach ($node_types as $node_type) { field_attach_delete_bundle('comment', 'comment_node_' . $node_type); - config('comment.settings.' . $node_type)->clear('comment'); - config('comment.settings.' . $node_type)->clear('comment_anonymous'); - config('comment.settings.' . $node_type)->clear('comment_controls'); - config('comment.settings.' . $node_type)->clear('comment_default_mode'); - config('comment.settings.' . $node_type)->clear('comment_default_order'); - config('comment.settings.' . $node_type)->clear('comment_default_per_page'); - config('comment.settings.' . $node_type)->clear('comment_form_location'); - config('comment.settings.' . $node_type)->clear('comment_preview'); - config('comment.settings.' . $node_type)->clear('comment_subject_field'); + config('comment.settings.' . $node_type)->delete(); } } diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index af69ce4..882dbd4 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -189,7 +189,7 @@ function comment_field_extra_fields() { $return = array(); foreach (node_type_get_types() as $type) { - if (config('comment.settings.' . $type->type)->get('comment_subject_field') == 1) { + if (config('comment.settings.' . $type->type)->get('comment_subject_field')) { $return['comment']['comment_node_' . $type->type] = array( 'form' => array( 'author' => array( @@ -471,7 +471,9 @@ function comment_block_configure($delta = '') { * Implements hook_block_save(). */ function comment_block_save($delta = '', $edit = array()) { - config('comment.settings')->set('comment_block_count', $edit['comment_block_count'])->save(); + config('comment.settings') + ->set('comment_block_count', $edit['comment_block_count']) + ->save(); } /** @@ -566,8 +568,9 @@ function comment_get_recent($number = 10) { * "page=X" if the page number is greater than zero; empty string otherwise. */ function comment_new_page_count($num_comments, $new_replies, Node $node) { - $mode = config('comment.settings.' . $node->type)->get('comment_default_mode'); - $comments_per_page = config('comment.settings.' . $node->type)->get('comment_default_per_page'); + $config = config('comment.settings.' . $node->type); + $mode = $config->get('comment_default_mode'); + $comments_per_page = $config->get('comment_default_per_page'); $pagenum = NULL; $flat = $mode == COMMENT_MODE_FLAT ? TRUE : FALSE; if ($num_comments <= $comments_per_page) { @@ -1276,7 +1279,6 @@ function comment_submit_config($form, &$form_state) { ->set('comment_form_location', $form_state['values']['comment_form_location']) ->set('comment_preview', $form_state['values']['comment_preview']) ->save(); - watchdog('comment', 'CMI configuration variables updated for node type %type', array('%type' => $form['#node_type']->type)); } /** diff --git a/core/modules/comment/lib/Drupal/comment/CommentFormController.php b/core/modules/comment/lib/Drupal/comment/CommentFormController.php index 52dd739..69888f5 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentFormController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentFormController.php @@ -159,7 +159,7 @@ class CommentFormController extends EntityFormController { '#title' => t('Subject'), '#maxlength' => 64, '#default_value' => $comment->subject, - '#access' => config('comment.settings.' . $node->type)->get('comment_subject_field') == 1, + '#access' => config('comment.settings.' . $node->type)->get('comment_subject_field'), ); // Used for conditional validation of author fields.