diff --git a/core/modules/field/field.install b/core/modules/field/field.install index 16b09e1c925..8aba2da4684 100644 --- a/core/modules/field/field.install +++ b/core/modules/field/field.install @@ -103,10 +103,9 @@ function field_schema() { 'active' => array('active'), 'storage_active' => array('storage_active'), 'deleted' => array('deleted'), - // Used by field_modules_disabled(). + // Used by field_sync_field_status(). 'module' => array('module'), 'storage_module' => array('storage_module'), - // Used by field_associate_fields(). 'type' => array('type'), 'storage_type' => array('storage_type'), ), diff --git a/core/modules/field/field.module b/core/modules/field/field.module index 9129fd51223..d1e4f73582a 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -362,11 +362,12 @@ function field_theme() { /** * Implements hook_cron(). - * - * Purges some deleted Field API data, if any exists. */ function field_cron() { + // Refresh the 'active' status of fields. field_sync_field_status(); + + // Do a pass of purging on deleted Field API data, if any exists. $limit = variable_get('field_purge_batch_size', 10); field_purge_batch($limit); } @@ -412,10 +413,29 @@ function field_system_info_alter(&$info, $file, $type) { * Implements hook_flush_caches(). */ function field_flush_caches() { + // Refresh the 'active' status of fields. field_sync_field_status(); + + // Request a flush of our cache table. return array('field'); } +/** + * Implements hook_modules_enabled(). + */ +function field_modules_enabled($modules) { + // Refresh the 'active' status of fields. + field_sync_field_status(); +} + +/** + * Implements hook_modules_disabled(). + */ +function field_modules_disabled($modules) { + // Refresh the 'active' status of fields. + field_sync_field_status(); +} + /** * Refreshes the 'active' and 'storage_active' columns for fields. */ @@ -449,18 +469,18 @@ function field_sync_field_status() { function field_associate_fields($module) { // Associate field types. $field_types = (array) module_invoke($module, 'field_info'); - foreach ($field_types as $name => $field_info) { + if ($field_types) { db_update('field_config') ->fields(array('module' => $module, 'active' => 1)) - ->condition('type', $name) + ->condition('type', array_keys($field_types)) ->execute(); } // Associate storage backends. $storage_types = (array) module_invoke($module, 'field_storage_info'); - foreach ($storage_types as $name => $storage_info) { + if ($storage_types) { db_update('field_config') ->fields(array('storage_module' => $module, 'storage_active' => 1)) - ->condition('storage_type', $name) + ->condition('storage_type', array_keys($storage_types)) ->execute(); } } diff --git a/core/modules/field/tests/field.test b/core/modules/field/tests/field.test index 0733bd013d9..bb3206acc14 100644 --- a/core/modules/field/tests/field.test +++ b/core/modules/field/tests/field.test @@ -2357,7 +2357,6 @@ class FieldCrudTestCase extends FieldTestCase { $this->assertTrue($field_definition <= $field, t('The field was properly read.')); module_disable($modules, FALSE); - drupal_flush_all_caches(); $fields = field_read_fields(array('field_name' => $field_name), array('include_inactive' => TRUE)); $this->assertTrue(isset($fields[$field_name]) && $field_definition < $field, t('The field is properly read when explicitly fetching inactive fields.')); @@ -2370,7 +2369,6 @@ class FieldCrudTestCase extends FieldTestCase { $module = array_shift($modules); module_enable(array($module), FALSE); - drupal_flush_all_caches(); } // Check that the field is active again after all modules have been diff --git a/core/modules/taxonomy/taxonomy.test b/core/modules/taxonomy/taxonomy.test index aa3c20993a6..fe77fec6cae 100644 --- a/core/modules/taxonomy/taxonomy.test +++ b/core/modules/taxonomy/taxonomy.test @@ -375,7 +375,6 @@ class TaxonomyVocabularyUnitTest extends TaxonomyWebTestCase { field_create_instance($this->instance); module_disable(array('taxonomy')); - drupal_flush_all_caches(); require_once DRUPAL_ROOT . '/core/includes/install.inc'; drupal_uninstall_modules(array('taxonomy')); module_enable(array('taxonomy'));