Followup for #943772: field_delete_field() and others fail for inactive fields :
The patch that got committed over there made it so that the 'active' status of fields ('is the field type module enabled ?") is rechecked on cache flush rather than in hook_modules_enabled() / hook_modules_disabled() previously.
From comment #167 over there :
"HEAD currently runs (the equivalent of) field_sync_field_status() in hook_modules_[enabled|disabled](). We want it to run on hook_flush_cache(), so we moved it there. It still runs when the "administer modules" form is submitted and in "drush enable / disable", but not with direct API calls to module_[enable|disable](), which a lot of tests do. Adding explicit drupal_flush_all_caches() calls fixes it, but with the current patch, direct calls to module_[enable|disable]() do not update the field 'active' column like it did before. Happens on next cache flush.
We could re-add a field_sync_field_status() call in hook_modules_[enabled|disabled](), but that would cause the code to run twice on regular enable / disable through the UI or drush, once during module_[enable|disable](), once during the subsequent drupal_flush_all_caches(). Not that bad, probably..."
catch approved the approach in #178, and it was agreed to postpone to a followup.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | field_modules_enabled-1264728-10.patch | 4.41 KB | albert volkman |
| #6 | field_modules_enabled-1264728-6.patch | 4.35 KB | yched |
| #5 | field_modules_enabled-1264728-5.patch | 4.77 KB | yched |
| #3 | field_modules_enabled-1264728-3.patch | 4.74 KB | yched |
| #1 | field_modules_enabled-1264728-1.patch | 4.66 KB | yched |
Comments
Comment #1
yched commentedPatch attached :
- Reintroduces field.module's implementations of hook_modules_[enabled|disabled](), that call field_sync_field_status().
- Removes the explicit field_sync_field_status() calls that were added in #943772: field_delete_field() and others fail for inactive fields in tests that perform direct module_[enable|disable]() calls.
- Replaces the stale / inaccurate mention of field_modules_disabled() in a comment in field_schema() (indexes)
- Additionally, optimizes a bit the field_associate_fields() part ("make sure fields are associated with their field type module") - one query per field-type module, instead of one query per field type.
Comment #2
catchLooks good to me but it's been a long day so falling short of RTBC.
Comment #3
yched commentedRorolled for /core folder, + bump :-)
Comment #5
yched commentedTry again
Comment #6
yched commentedRerolled after #366152: field_modules_uninstalled still exists, despite being an empty foreach loop..
Comment #7
sunThis makes sense and looks good to go for me.
Comment #8
sun#6: field_modules_enabled-1264728-6.patch queued for re-testing.
Comment #9
dries commentedCommitted to 8.x. Moving to 7.x for a backport.
Comment #10
albert volkman commentedD7 backport.
Comment #11
xjmBackport matches; no D8-specific code. :)
Comment #12
webchickThis looks like a great little clean-up. Thanks!
Committed and pushed to 7.x.