Commit fc7c985b authored by Dries's avatar Dries

- Patch #1264728 by yched: Refresh field 'active' state in module_enable() / _disable().

parent e341d8ec
......@@ -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'),
),
......
......@@ -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();
}
}
......
......@@ -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
......
......@@ -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'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment