function features_get_signature in Features 7.2
Same name and namespace in other branches
- 6 features.export.inc \features_get_signature()
- 7 features.export.inc \features_get_signature()
Gets an md5 signature for a the state of an object in code or database.
Wrapper around features_get_[storage]() to return an md5 hash of a normalized defaults/normal object array. Can be used to compare normal/default states of a module's component.
Parameters
string $state: One of 'cache', 'default' or 'normal'.
string $module_name: A module name.
string $component: A component name, e.g. 'field_instance'.
bool $reset: If TRUE, the static cache for features_get_default() or features_get_normal() will be reset.
Return value
string|false An md5 signature, or FALSE if not found.
3 calls to features_get_signature()
- features_get_component_states in ./
features.export.inc - Retrieve an array of features/components and their current states.
- features_set_signature in ./
features.export.inc - Updates a module/component signature in the database.
- features_update_6101 in ./
features.install - Update 6101: Set codestate signature for all features.
1 string reference to 'features_get_signature'
- features_update_6101 in ./
features.install - Update 6101: Set codestate signature for all features.
File
- ./
features.export.inc, line 897 - Contains functions that export configuration into feature modules.
Code
function features_get_signature($state = 'default', $module_name, $component, $reset = FALSE) {
switch ($state) {
case 'cache':
// Load the last known stored signature from the database.
switch (_features_get_signature_storage_type()) {
case 'table':
// The database is fully updated.
// All signatures are stored in a dedicated database table.
$qr = db_select('features_signature', 'fs')
->fields('fs', array(
'signature',
))
->condition('module', $module_name)
->condition('component', $component)
->execute();
return $qr ? $qr
->fetchField() : FALSE;
case 'cache':
// The database is not fully updated, only to schema version 7201.
// Signatures are stored in a cache table.
$cache = cache_get('features_codecache', 'cache_featurestate');
if (isset($cache->data[$module_name][$component])) {
return $cache->data[$module_name][$component];
}
// No stored signature for this component.
return FALSE;
case 'variable':
default:
// The database is not fully updated, schema version before 7201.
// Signatures are stored in a variable.
$signaturess = variable_get('features_codecache', array());
if (isset($signaturess[$module_name][$component])) {
return $signaturess[$module_name][$component];
}
// No stored signature for this component.
return FALSE;
}
case 'default':
// Get the component data as currently in code.
$objects = features_get_default($component, $module_name, TRUE, $reset);
break;
case 'normal':
// Get the component data as currently in the database.
$objects = features_get_normal($component, $module_name, $reset);
break;
}
if (!empty($objects)) {
// Build a signature hash from the component data.
features_sanitize($objects, $component);
return md5(_features_linetrim(features_var_export($objects)));
}
return FALSE;
}