summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2012-03-01 21:21:29 -0800
committerwebchick <webchick@24967.no-reply.drupal.org>2012-03-01 21:21:29 -0800
commit7500ee40f48666c71736fd0527aa61974a37209f (patch)
tree0c22d20e861b1c1e162fd6e2829f95833aa309e0 /modules
parentdf911f3f5081b258eda937c4791eb854fe2720be (diff)
downloadbrdo-7500ee40f48666c71736fd0527aa61974a37209f.tar.gz
brdo-7500ee40f48666c71736fd0527aa61974a37209f.tar.bz2
Issue #1264728 by yched, Albert Volkman: Refresh field 'active' state in module_enable() / _disable().
Diffstat (limited to 'modules')
-rw-r--r--modules/field/field.install3
-rw-r--r--modules/field/field.module32
-rw-r--r--modules/field/tests/field.test2
-rw-r--r--modules/taxonomy/taxonomy.test1
4 files changed, 27 insertions, 11 deletions
diff --git a/modules/field/field.install b/modules/field/field.install
index d56eb904c..407b5faff 100644
--- a/modules/field/field.install
+++ b/modules/field/field.install
@@ -99,14 +99,13 @@ function field_schema() {
'primary key' => array('id'),
'indexes' => array(
'field_name' => array('field_name'),
- // Used by field_read_fields().
+ // Used by field_sync_field_status().
'active' => array('active'),
'storage_active' => array('storage_active'),
'deleted' => array('deleted'),
// Used by field_modules_disabled().
'module' => array('module'),
'storage_module' => array('storage_module'),
- // Used by field_associate_fields().
'type' => array('type'),
'storage_type' => array('storage_type'),
),
diff --git a/modules/field/field.module b/modules/field/field.module
index c2e5165e3..2625742d4 100644
--- a/modules/field/field.module
+++ b/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);
}
@@ -423,11 +424,30 @@ 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('cache_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.
*/
function field_sync_field_status() {
@@ -460,18 +480,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/modules/field/tests/field.test b/modules/field/tests/field.test
index 657f1f364..70dc1a62a 100644
--- a/modules/field/tests/field.test
+++ b/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/modules/taxonomy/taxonomy.test b/modules/taxonomy/taxonomy.test
index 39164190b..b99db8ee2 100644
--- a/modules/taxonomy/taxonomy.test
+++ b/modules/taxonomy/taxonomy.test
@@ -369,7 +369,6 @@ class TaxonomyVocabularyTestCase extends TaxonomyWebTestCase {
field_create_instance($this->instance);
module_disable(array('taxonomy'));
- drupal_flush_all_caches();
require_once DRUPAL_ROOT . '/includes/install.inc';
drupal_uninstall_modules(array('taxonomy'));
module_enable(array('taxonomy'));