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.

Comments

yched’s picture

Status: Active » Needs review
Issue tags: +Needs backport to D7
StatusFileSize
new4.66 KB

Patch 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.

catch’s picture

Looks good to me but it's been a long day so falling short of RTBC.

yched’s picture

StatusFileSize
new4.74 KB

Rorolled for /core folder, + bump :-)

Status: Needs review » Needs work

The last submitted patch, field_modules_enabled-1264728-3.patch, failed testing.

yched’s picture

Status: Needs work » Needs review
StatusFileSize
new4.77 KB

Try again

yched’s picture

sun’s picture

Status: Needs review » Reviewed & tested by the community

This makes sense and looks good to go for me.

sun’s picture

dries’s picture

Version: 8.x-dev » 7.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Committed to 8.x. Moving to 7.x for a backport.

albert volkman’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new4.41 KB

D7 backport.

xjm’s picture

Status: Needs review » Reviewed & tested by the community

Backport matches; no D8-specific code. :)

webchick’s picture

Status: Reviewed & tested by the community » Fixed

This looks like a great little clean-up. Thanks!

Committed and pushed to 7.x.

Automatically closed -- issue fixed for 2 weeks with no activity.