So there's no way to return back fields after module enabled again, also this blocks #731724: Convert comment settings into a field to make them work with CMI and non-node entities which was converted to annotations
steps to reproduce
1) enable telephone module
2) add telephone field to article
3) disable and then enable telephone module
4) visit admin/structure/types/manage/article/fields - no telephone field!
Also admin/reports/fields
Notice: Undefined index: field_tel in Drupal\field_ui\FieldListController->buildRow() (line 115 of core/modules/field_ui/lib/Drupal/field_ui/FieldListController.php).
Warning: Invalid argument supplied for foreach() in Drupal\field_ui\FieldListController->buildRow() (line 115 of core/modules/field_ui/lib/Drupal/field_ui/FieldListController.php).
Image may be NSFW.
Clik here to view.

<?php
foreach ($modules as $module => $module_info) {
// Collect field types and storage backends exposed by the module.
$field_types = (array) $module_handler->invoke($module, 'field_info');
$storage_types = (array) $module_handler->invoke($module, 'field_storage_info');
if ($field_types || $storage_types) {
foreach ($fields as $uuid => &$field) {
// Associate field types.
if (isset($field_types[$field['type']]) && ($field['module'] !== $module || !$field['active'])) {
$field['module'] = $module;
$field['active'] = TRUE;
$changed[$uuid] = $field;
}
?>
Attachment | Size | Status | Test result | Operations |
---|---|---|---|---|
field_list.png | 59.62 KB | Ignored | None | None |