function node_features_revert in Features 6
Same name and namespace in other branches
- 7.2 includes/features.node.inc \node_features_revert()
- 7 includes/features.node.inc \node_features_revert()
Implementation of hook_features_revert().
Parameters
$module: name of module to revert content for
File
- includes/
features.node.inc, line 135
Code
function node_features_revert($module = NULL) {
if ($default_types = features_get_default('node', $module)) {
foreach ($default_types as $type_name => $type_info) {
// We need to de-activate any missing fields. De-activating allows us to
// preserve data. We de-activate by setting the widget_active flag to 0;
// widget_active is incorrectly named, and really should be
// instance_active
if (module_exists('content')) {
// Our existing fields ($fields) needs to be the first argument here,
// so only fields that don't exist in code can be de-activated.
if ($deleted_fields = array_diff(content_features_fields_normal($type_name), content_features_fields_default($type_name))) {
foreach ($deleted_fields as $field_name) {
db_query("UPDATE {" . content_instance_tablename() . "} SET widget_active = 0 WHERE field_name = '%s' AND type_name = '%s'", $field_name, $type_name);
}
}
}
// Delete node types
// We don't use node_type_delete() because we do not actually
// want to delete the node type (and invoke hook_node_type()).
// This can lead to bad consequences like CCK deleting field
// storage in the DB.
db_query("DELETE FROM {node_type} WHERE type = '%s'", $type_name);
}
node_types_rebuild();
menu_rebuild();
}
}