1.20.x field.module | field_sync_field_status() |
Refreshes the 'active' and 'storage[active]' properties on fields.
Related topics
File
- modules/
field/ field.module, line 614 - Attach custom data fields to Backdrop entities.
Code
function field_sync_field_status() {
// Refresh the 'active' and 'storage_active' columns according to the current
// set of enabled modules.
$modules = module_list();
$fields = field_read_fields();
foreach ($modules as $module_name) {
field_associate_fields($module_name, $fields);
}
$fields = field_read_fields(array(), array('include_inactive' => TRUE, 'include_deleted' => TRUE));
foreach ($fields as $field) {
$current_field = $field;
$field['active'] = (int) in_array($field['module'], $modules);
$field['storage']['active'] = (int) in_array($field['storage']['module'], $modules);
if ($current_field !== $field) {
field_update_field($field);
}
}
}