You are here

function configuration_update_component_status in Configuration Management 7

Updates the status of a component after it was updated.

Parameters

$component: The type of component, i.e node, user_permissions, taxonomy.

$identifier: The identifier for the component, usually the machine name.

$items: Items from the activestore.

$items_code: Items loaded from the datastore.

$from_activestore: @todo A static variable that make not sense now we have to remove it.

8 calls to configuration_update_component_status()
configuration_check_field in includes/configuration.field.inc
configuration_check_filter in includes/configuration.filter.inc
configuration_check_image in includes/configuration.image.inc
configuration_check_menu_links in includes/configuration.menu.inc
configuration_check_node in includes/configuration.node.inc

... See full list

File

./configuration.module, line 1100
Module file for the configuration module, which enables the capture and management of configuration in Drupal.

Code

function configuration_update_component_status($component, $identifier, $items, $items_code, $from_activestore) {

  // @todo re-factory component status logic.
  // If this was the previous configuration in activestore don't mark this as changed.
  $config = configuration_get_configuration();
  $status = (int) $config[$component][$identifier]['status'];
  $md5_datastore = is_array($items_code) && array_key_exists($identifier, $items_code) ? md5(serialize($items_code[$identifier])) : '';
  $md5_activestore = is_array($items) && array_key_exists($identifier, $items) ? md5(serialize($items[$identifier])) : '';

  // @todo remove $from_activestore static variable all around since make no sense now.
  $from_activestore = $md5_activestore != $config[$component][$identifier]['hash'];

  // Configs in code are not the same as what was just saved in activestore.
  if ($md5_datastore != $md5_activestore) {
    $status |= $from_activestore ? CONFIGURATION_ACTIVESTORE_OVERRIDDEN : CONFIGURATION_DATASTORE_OVERRIDDEN;
  }
  else {
    $status = CONFIGURATION_IN_SYNC;
    configuration_set_hash($component, $identifier, $md5_activestore);
  }

  // When checking for new configurations, check to see if configurations are
  // the same in datastore as last activestore. Remove the datastore overridden.
  if ($md5_datastore == $config[$component][$identifier]['hash']) {
    $status = $status & ~CONFIGURATION_DATASTORE_OVERRIDDEN;
  }
  configuration_set_status($component, $identifier, $status);

  // Store the config array in cache for easy access
  $configuration[$component][$identifier]['datastore'] = is_array($items_code) && array_key_exists($identifier, $items_code) ? $items_code[$identifier] : '';
  $configuration[$component][$identifier]['activestore'] = is_array($items) && array_key_exists($identifier, $items) ? $items[$identifier] : '';
  cache_set("{$component}:{$identifier}", $configuration, 'cache_configuration');
}