function features_get_component_states in Features 7
Same name and namespace in other branches
- 6 features.export.inc \features_get_component_states()
- 7.2 features.export.inc \features_get_component_states()
Retrieve an array of features/components and their current states.
6 calls to features_get_component_states()
- drush_features_revert in ./
features.drush.inc - Revert a feature to it's code definition. Optionally accept a list of components to revert.
- FeaturesUserTestCase::test in tests/
features.test - Run test.
- features_admin_components in ./
features.admin.inc - Display the components of a feature.
- features_detect_overrides in ./
features.export.inc - Detect differences between DB and code components of a feature.
- features_get_storage in ./
features.export.inc - Get a summary storage state for a feature.
File
- ./
features.export.inc, line 751
Code
function features_get_component_states($features = array(), $rebuild_only = TRUE, $reset = FALSE) {
static $cache;
if (!isset($cache) || $reset) {
$cache = array();
}
$features = !empty($features) ? $features : array_keys(features_get_features());
// Retrieve only rebuildable components if requested.
features_include();
$components = array_keys(features_get_components());
if ($rebuild_only) {
foreach ($components as $k => $component) {
if (!features_hook($component, 'features_rebuild')) {
unset($components[$k]);
}
}
}
foreach ($features as $feature) {
$cache[$feature] = isset($cache[$feature]) ? $cache[$feature] : array();
if (module_exists($feature)) {
foreach ($components as $component) {
if (!isset($cache[$feature][$component])) {
$normal = features_get_signature('normal', $feature, $component, $reset);
$default = features_get_signature('default', $feature, $component, $reset);
$codecache = features_get_signature('cache', $feature, $component, $reset);
$semaphore = features_semaphore('get', $component);
// DB and code states match, there is nothing more to check.
if ($normal == $default) {
$cache[$feature][$component] = FEATURES_DEFAULT;
// Stale semaphores can be deleted.
features_semaphore('del', $component);
// Update code cache if it is stale, clear out semaphore if it stale.
if ($default != $codecache) {
features_set_signature($feature, $component, $default);
}
}
else {
if (!features_hook($component, 'features_rebuild')) {
$cache[$feature][$component] = FEATURES_OVERRIDDEN;
}
else {
if (empty($semaphore)) {
// Exception for dependencies. Dependencies are always rebuildable.
if ($component === 'dependencies') {
$cache[$feature][$component] = FEATURES_REBUILDABLE;
}
else {
// Code has not changed, but DB does not match. User has DB overrides.
if ($codecache == $default) {
$cache[$feature][$component] = FEATURES_OVERRIDDEN;
}
else {
if (empty($codecache) || $codecache == $normal) {
$cache[$feature][$component] = FEATURES_REBUILDABLE;
}
else {
if ($codecache != $default) {
$cache[$feature][$component] = FEATURES_NEEDS_REVIEW;
}
}
}
}
}
else {
// Semaphore is still within processing horizon. Do nothing.
if (REQUEST_TIME - $semaphore < FEATURES_SEMAPHORE_TIMEOUT) {
$cache[$feature][$component] = FEATURES_REBUILDING;
}
else {
$cache[$feature][$component] = FEATURES_REBUILDABLE;
}
}
}
}
}
}
}
}
// Filter cached components on the way out to ensure that even if we have
// cached more data than has been requested, the return value only reflects
// the requested features/components.
$return = $cache;
$return = array_intersect_key($return, array_flip($features));
foreach ($return as $k => $v) {
$return[$k] = array_intersect_key($return[$k], array_flip($components));
}
return $return;
}