Refreshes the 'active' and 'storage_active' columns for fields.
function field_sync_field_status() {
// Refresh the 'active' and 'storage_active' columns according to the current
// set of enabled modules.
$modules = module_list();
foreach ($modules as $module_name) {
field_associate_fields($module_name);
}
db_update('field_config')
->fields(array(
'active' => 0,
))
->condition('module', $modules, 'NOT IN')
->execute();
db_update('field_config')
->fields(array(
'storage_active' => 0,
))
->condition('storage_module', $modules, 'NOT IN')
->execute();
}