diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 1a3580f..a940017 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -376,7 +376,7 @@ function comment_node_type_delete($info) { */ function _comment_body_field_create($info) { // Create the field if needed. - if (!field_read_field('comment_body', array('include_inactive' => TRUE))) { + if (!field_read_field('comment_body')) { $field = array( 'field_name' => 'comment_body', 'type' => 'text_long', @@ -385,7 +385,7 @@ function _comment_body_field_create($info) { field_create_field($field); } // Create the instance if needed. - if (!field_read_instance('comment', 'comment_body', 'comment_node_' . $info->type, array('include_inactive' => TRUE))) { + if (!field_read_instance('comment', 'comment_body', 'comment_node_' . $info->type)) { field_attach_create_bundle('comment', 'comment_node_' . $info->type); // Attaches the body field by default. $instance = array( diff --git a/core/modules/field/field.attach.inc b/core/modules/field/field.attach.inc index 34826cb..207564c 100644 --- a/core/modules/field/field.attach.inc +++ b/core/modules/field/field.attach.inc @@ -1346,10 +1346,7 @@ function field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new) { * The bundle to delete. */ function field_attach_delete_bundle($entity_type, $bundle) { - // First, delete the instances themselves. field_read_instances() must be - // used here since field_info_instances() does not return instances for - // disabled entity types or bundles. - $instances = field_read_instances(array('entity_type' => $entity_type, 'bundle' => $bundle), array('include_inactive' => 1)); + $instances = field_info_instances($entity_type, $bundle); foreach ($instances as $instance) { field_delete_instance($instance); } diff --git a/core/modules/field/field.crud.inc b/core/modules/field/field.crud.inc index f9c96c9..ad6a04a 100644 --- a/core/modules/field/field.crud.inc +++ b/core/modules/field/field.crud.inc @@ -75,13 +75,11 @@ function field_create_field($field) { array('%name' => $field['field_name']))); } - // Ensure the field name is unique over active and disabled fields. + // Ensure the field name is unique. // We do not care about deleted fields. - $prior_field = field_read_field($field['field_name'], array('include_inactive' => TRUE)); + $prior_field = field_read_field($field['field_name']); if (!empty($prior_field)) { - $message = $prior_field['active']? - t('Attempt to create field name %name which already exists and is active.', array('%name' => $field['field_name'])): - t('Attempt to create field name %name which already exists, although it is inactive.', array('%name' => $field['field_name'])); + $message = t('Attempt to create field name %name which already exists.', array('%name' => $field['field_name'])); throw new FieldException($message); } @@ -113,7 +111,6 @@ function field_create_field($field) { // settings that impact column definitions). $field['settings'] += field_info_field_settings($field['type']); $field['module'] = $field_type['module']; - $field['active'] = 1; // Provide default storage. $field['storage'] += array( @@ -128,7 +125,6 @@ function field_create_field($field) { // Provide default storage settings. $field['storage']['settings'] += field_info_storage_settings($field['storage']['type']); $field['storage']['module'] = $storage_type['module']; - $field['storage']['active'] = 1; // Collect storage information. module_load_install($field['module']); $schema = (array) module_invoke($field['module'], 'field_schema', $field); @@ -148,7 +144,7 @@ function field_create_field($field) { // have its own column and is not automatically populated when the field is // read. $data = $field; - unset($data['columns'], $data['field_name'], $data['type'], $data['active'], $data['module'], $data['storage_type'], $data['storage_active'], $data['storage_module'], $data['locked'], $data['cardinality'], $data['deleted']); + unset($data['columns'], $data['field_name'], $data['type'], $data['module'], $data['storage_type'], $data['storage_module'], $data['locked'], $data['cardinality'], $data['deleted']); // Additionally, do not save the 'bundles' property populated by // field_info_field(). unset($data['bundles']); @@ -157,10 +153,8 @@ function field_create_field($field) { 'field_name' => $field['field_name'], 'type' => $field['type'], 'module' => $field['module'], - 'active' => $field['active'], 'storage_type' => $field['storage']['type'], 'storage_module' => $field['storage']['module'], - 'storage_active' => $field['storage']['active'], 'locked' => $field['locked'], 'data' => $data, 'cardinality' => $field['cardinality'], @@ -274,7 +268,7 @@ function field_update_field($field) { // have its own column and is not automatically populated when the field is // read. $data = $field; - unset($data['columns'], $data['field_name'], $data['type'], $data['locked'], $data['module'], $data['cardinality'], $data['active'], $data['deleted']); + unset($data['columns'], $data['field_name'], $data['type'], $data['locked'], $data['module'], $data['cardinality'], $data['deleted']); // Additionally, do not save the 'bundles' property populated by // field_info_field(). unset($data['bundles']); @@ -304,8 +298,8 @@ function field_update_field($field) { * The field name to read. * @param array $include_additional * The default behavior of this function is to not return a field that - * is inactive. Setting - * $include_additional['include_inactive'] to TRUE will override this + * is deleted. Setting + * $include_additional['include_deleted'] to TRUE will override this * behavior. * @return * A field definition array, or FALSE. @@ -322,10 +316,8 @@ function field_read_field($field_name, $include_additional = array()) { * An array of conditions to match against. * @param array $include_additional * The default behavior of this function is to not return fields that - * are inactive or have been deleted. Setting - * $include_additional['include_inactive'] or - * $include_additional['include_deleted'] to TRUE will override this - * behavior. + * have been deleted. Setting $include_additional['include_deleted'] to TRUE + * will override this behavior. * @return * An array of fields matching $params. If * $include_additional['include_deleted'] is TRUE, the array is keyed @@ -339,11 +331,6 @@ function field_read_fields($params = array(), $include_additional = array()) { foreach ($params as $key => $value) { $query->condition($key, $value); } - if (!isset($include_additional['include_inactive']) || !$include_additional['include_inactive']) { - $query - ->condition('fc.active', 1) - ->condition('fc.storage_active', 1); - } $include_deleted = (isset($include_additional['include_deleted']) && $include_additional['include_deleted']); if (!$include_deleted) { $query->condition('fc.deleted', 0); @@ -357,10 +344,8 @@ function field_read_fields($params = array(), $include_additional = array()) { $field['field_name'] = $record['field_name']; $field['type'] = $record['type']; $field['module'] = $record['module']; - $field['active'] = $record['active']; $field['storage']['type'] = $record['storage_type']; $field['storage']['module'] = $record['storage_module']; - $field['storage']['active'] = $record['storage_active']; $field['locked'] = $record['locked']; $field['cardinality'] = $record['cardinality']; $field['translatable'] = $record['translatable']; @@ -454,7 +439,7 @@ function field_delete_field($field_name) { function field_create_instance($instance) { $field = field_read_field($instance['field_name']); if (empty($field)) { - throw new FieldException(t("Attempt to create an instance of a field @field_name that doesn't exist or is currently inactive.", array('@field_name' => $instance['field_name']))); + throw new FieldException(t("Attempt to create an instance of a field @field_name that doesn't exist.", array('@field_name' => $instance['field_name']))); } // Check that the required properties exists. if (empty($instance['entity_type'])) { @@ -482,8 +467,6 @@ function field_create_instance($instance) { // Problem : this would mean that a UI module cannot update an instance with a disabled formatter. // Ensure the field instance is unique within the bundle. - // We only check for instances of active fields, since adding an instance of - // a disabled field is not supported. $prior_instance = field_read_instance($instance['entity_type'], $instance['field_name'], $instance['bundle']); if (!empty($prior_instance)) { $message = t('Attempt to create an instance of field @field_name on bundle @bundle that already has an instance of that field.', array('@field_name' => $instance['field_name'], '@bundle' => $instance['bundle'])); @@ -525,9 +508,8 @@ function field_update_instance($instance) { throw new FieldException(t('Attempt to update an instance of a nonexistent field @field.', array('@field' => $instance['field_name']))); } - // Check that the field instance exists (even if it is inactive, since we - // want to be able to replace inactive widgets with new ones). - $prior_instance = field_read_instance($instance['entity_type'], $instance['field_name'], $instance['bundle'], array('include_inactive' => TRUE)); + // Check that the field instance exists. + $prior_instance = field_read_instance($instance['entity_type'], $instance['field_name'], $instance['bundle']); if (empty($prior_instance)) { throw new FieldException(t("Attempt to update an instance of field @field on bundle @bundle that doesn't exist.", array('@field' => $instance['field_name'], '@bundle' => $instance['bundle']))); } @@ -650,10 +632,8 @@ function _field_write_instance($instance, $update = FALSE) { * The bundle to which the field is bound. * @param array $include_additional * The default behavior of this function is to not return an instance that - * has been deleted, or whose field is inactive. Setting - * $include_additional['include_inactive'] or - * $include_additional['include_deleted'] to TRUE will override this - * behavior. + * has been deleted. Setting $include_additional['include_deleted'] to TRUE + * will override this behavior. * @return * An instance structure, or FALSE. */ @@ -671,15 +651,13 @@ function field_read_instance($entity_type, $field_name, $bundle, $include_additi * field_config_instance table. If NULL, all instances will be returned. * @param $include_additional * The default behavior of this function is to not return field - * instances that have been marked deleted, or whose field is inactive. - * Setting $include_additional['include_inactive'] or - * $include_additional['include_deleted'] to TRUE will override this + * instances that have been marked deleted. + * Setting $include_additional['include_deleted'] to TRUE will override this * behavior. * @return * An array of instances matching the arguments. */ function field_read_instances($params = array(), $include_additional = array()) { - $include_inactive = isset($include_additional['include_inactive']) && $include_additional['include_inactive']; $include_deleted = isset($include_additional['include_deleted']) && $include_additional['include_deleted']; $query = db_select('field_config_instance', 'fci', array('fetch' => PDO::FETCH_ASSOC)); @@ -690,11 +668,6 @@ function field_read_instances($params = array(), $include_additional = array()) foreach ($params as $key => $value) { $query->condition('fci.' . $key, $value); } - if (!$include_inactive) { - $query - ->condition('fc.active', 1) - ->condition('fc.storage_active', 1); - } if (!$include_deleted) { $query->condition('fc.deleted', 0); $query->condition('fci.deleted', 0); @@ -707,18 +680,16 @@ function field_read_instances($params = array(), $include_additional = array()) // Filter out instances on unknown entity types (for instance because the // module exposing them was disabled). $entity_info = entity_get_info($record['entity_type']); - if ($include_inactive || $entity_info) { - $instance = unserialize($record['data']); - $instance['id'] = $record['id']; - $instance['field_id'] = $record['field_id']; - $instance['field_name'] = $record['field_name']; - $instance['entity_type'] = $record['entity_type']; - $instance['bundle'] = $record['bundle']; - $instance['deleted'] = $record['deleted']; - - module_invoke_all('field_read_instance', $instance); - $instances[] = $instance; - } + $instance = unserialize($record['data']); + $instance['id'] = $record['id']; + $instance['field_id'] = $record['field_id']; + $instance['field_name'] = $record['field_name']; + $instance['entity_type'] = $record['entity_type']; + $instance['bundle'] = $record['bundle']; + $instance['deleted'] = $record['deleted']; + + module_invoke_all('field_read_instance', $instance); + $instances[] = $instance; } return $instances; } diff --git a/core/modules/field/field.info.inc b/core/modules/field/field.info.inc index 78bc62e..144b41c 100644 --- a/core/modules/field/field.info.inc +++ b/core/modules/field/field.info.inc @@ -172,14 +172,13 @@ function _field_info_collate_types_reset() { * @return * An associative array containing: * - fields: Array of existing fields, keyed by field ID. This element - * lists deleted and non-deleted fields, but not inactive ones. + * lists deleted and non-deleted fields. * Each field has an additional element, 'bundles', which is an array * of all non-deleted instances of that field. * - field_ids: Array of field IDs, keyed by field name. This element - * only lists non-deleted, active fields. + * only lists non-deleted fields. * - instances: Array of existing instances, keyed by entity type, bundle - * name and field name. This element only lists non-deleted instances - * whose field is active. + * name and field name. This element only lists non-deleted instances. * * @see _field_info_collate_fields_reset() */ @@ -617,9 +616,8 @@ function field_info_fields() { * * @param $field_name * The name of the field to retrieve. $field_name can only refer to a - * non-deleted, active field. For deleted fields, use - * field_info_field_by_id(). To retrieve information about inactive fields, - * use field_read_fields(). + * non-deleted field. For deleted fields, use + * field_info_field_by_id(). * * @return * The field array, as returned by field_read_fields(), with an @@ -640,7 +638,7 @@ function field_info_field($field_name) { * * @param $field_id * The id of the field to retrieve. $field_id can refer to a - * deleted field, but not an inactive one. + * deleted field. * * @return * The field array, as returned by field_read_fields(), with an diff --git a/core/modules/field/field.install b/core/modules/field/field.install index 8aba2da..81d24ad 100644 --- a/core/modules/field/field.install +++ b/core/modules/field/field.install @@ -36,13 +36,6 @@ function field_schema() { 'default' => '', 'description' => 'The module that implements the field type.', ), - 'active' => array( - 'type' => 'int', - 'size' => 'tiny', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'Boolean indicating whether the module that implements the field type is enabled.', - ), 'storage_type' => array( 'type' => 'varchar', 'length' => 128, @@ -56,13 +49,6 @@ function field_schema() { 'default' => '', 'description' => 'The module that implements the storage backend.', ), - 'storage_active' => array( - 'type' => 'int', - 'size' => 'tiny', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'Boolean indicating whether the module that implements the storage backend is enabled.', - ), 'locked' => array( 'type' => 'int', 'size' => 'tiny', @@ -100,8 +86,6 @@ function field_schema() { 'indexes' => array( 'field_name' => array('field_name'), // Used by field_read_fields(). - 'active' => array('active'), - 'storage_active' => array('storage_active'), 'deleted' => array('deleted'), // Used by field_sync_field_status(). 'module' => array('module'), @@ -181,7 +165,6 @@ function _update_7000_field_create_field(&$field) { 'settings' => array(), 'indexes' => array(), 'deleted' => 0, - 'active' => 1, ); // Set storage. @@ -189,7 +172,6 @@ function _update_7000_field_create_field(&$field) { 'type' => 'field_sql_storage', 'settings' => array(), 'module' => 'field_sql_storage', - 'active' => 1, ); // Fetch the field schema to initialize columns and indexes. The field module @@ -207,7 +189,7 @@ function _update_7000_field_create_field(&$field) { // have its own column and is not automatically populated when the field is // read. $data = $field; - unset($data['columns'], $data['field_name'], $data['type'], $data['active'], $data['module'], $data['storage_type'], $data['storage_active'], $data['storage_module'], $data['locked'], $data['cardinality'], $data['deleted']); + unset($data['columns'], $data['field_name'], $data['type'], $data['module'], $data['storage_type'], $data['storage_module'], $data['locked'], $data['cardinality'], $data['deleted']); // Additionally, do not save the 'bundles' property populated by // field_info_field(). unset($data['bundles']); @@ -217,10 +199,8 @@ function _update_7000_field_create_field(&$field) { 'field_name' => $field['field_name'], 'type' => $field['type'], 'module' => $field['module'], - 'active' => (int) $field['active'], 'storage_type' => $field['storage']['type'], 'storage_module' => $field['storage']['module'], - 'storage_active' => (int) $field['storage']['active'], 'locked' => (int) $field['locked'], 'data' => serialize($data), 'cardinality' => $field['cardinality'], @@ -301,7 +281,7 @@ function _update_7000_field_delete_instance($field_name, $entity_type, $bundle) * Utility function: fetch all the field definitions from the database. * * Warning: unlike the field_read_fields() API function, this function returns - * all fields by default, including deleted and inactive fields, unless + * all fields by default, including deleted fields, unless * specified otherwise in the $conditions parameter. * * @param $conditions @@ -329,10 +309,8 @@ function _update_7000_field_read_fields(array $conditions = array(), $key = 'id' $field['field_name'] = $record['field_name']; $field['type'] = $record['type']; $field['module'] = $record['module']; - $field['active'] = $record['active']; $field['storage']['type'] = $record['storage_type']; $field['storage']['module'] = $record['storage_module']; - $field['storage']['active'] = $record['storage_active']; $field['locked'] = $record['locked']; $field['cardinality'] = $record['cardinality']; $field['translatable'] = $record['translatable']; diff --git a/core/modules/field/field.module b/core/modules/field/field.module index 1ea128b..1dbdc61 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -78,8 +78,6 @@ require_once DRUPAL_ROOT . '/core/modules/field/field.form.inc'; * field in the UI. Defaults to FALSE. * - module (string, read-only): The name of the module that implements the * field type. - * - active (integer, read-only): TRUE if the module that implements the field - * type is currently enabled, FALSE otherwise. * - deleted (integer, read-only): TRUE if this field has been deleted, FALSE * otherwise. Deleted fields are ignored by the Field Attach API. This * property exists because fields can be marked for deletion but only @@ -109,8 +107,6 @@ require_once DRUPAL_ROOT . '/core/modules/field/field.form.inc'; * are defined by modules that implement hook_field_storage_info(). * - module (string, read-only): The name of the module that implements the * storage backend. - * - active (integer, read-only): TRUE if the module that implements the - * storage backend is currently enabled, FALSE otherwise. * - settings (array): A sub-array of key/value pairs of settings. Each * storage backend defines and documents its own settings. * @@ -334,103 +330,20 @@ function field_theme() { * Implements hook_cron(). */ 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); } /** - * Implements hook_system_info_alter(). - * - * Goes through a list of all modules that provide a field type, and makes them - * required if there are any active fields of that type. - */ -function field_system_info_alter(&$info, $file, $type) { - if ($type == 'module' && module_hook($file->name, 'field_info')) { - $fields = field_read_fields(array('module' => $file->name), array('include_deleted' => TRUE)); - if ($fields) { - $info['required'] = TRUE; - - // Provide an explanation message (only mention pending deletions if there - // remains no actual, non-deleted fields) - $non_deleted = FALSE; - foreach ($fields as $field) { - if (empty($field['deleted'])) { - $non_deleted = TRUE; - break; - } - } - if ($non_deleted) { - if (module_exists('field_ui')) { - $explanation = t('Field type(s) in use - see !link', array('!link' => l(t('Field list'), 'admin/reports/fields'))); - } - else { - $explanation = t('Fields type(s) in use'); - } - } - else { - $explanation = t('Fields pending deletion'); - } - $info['explanation'] = $explanation; - } - } -} - -/** * 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. + // 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. - */ -function field_sync_field_status() { - // Refresh the 'active' and 'storage_active' columns according to the current - // set of enabled modules. - $all_modules = system_rebuild_module_data(); - $modules = array(); - foreach ($all_modules as $module_name => $module) { - if ($module->status) { - $modules[] = $module_name; - field_associate_fields($module_name); - } - } - db_update('field_config') - ->fields(array('active' => 0)) - ->condition('module', $modules, 'NOT IN') - ->execute(); - db_update('field_config') - ->fields(array('storage_active' => 0)) - ->condition('storage_module', $modules, 'NOT IN') - ->execute(); -} - -/** * Allows a module to update the database for fields and columns it controls. * * @param $module @@ -441,7 +354,7 @@ function field_associate_fields($module) { $field_types = (array) module_invoke($module, 'field_info'); if ($field_types) { db_update('field_config') - ->fields(array('module' => $module, 'active' => 1)) + ->fields(array('module' => $module)) ->condition('type', array_keys($field_types)) ->execute(); } @@ -449,7 +362,7 @@ function field_associate_fields($module) { $storage_types = (array) module_invoke($module, 'field_storage_info'); if ($storage_types) { db_update('field_config') - ->fields(array('storage_module' => $module, 'storage_active' => 1)) + ->fields(array('storage_module' => $module)) ->condition('storage_type', array_keys($storage_types)) ->execute(); } diff --git a/core/modules/field/modules/field_sql_storage/field_sql_storage.install b/core/modules/field/modules/field_sql_storage/field_sql_storage.install index 4a3a00e..5a0b2f0 100644 --- a/core/modules/field/modules/field_sql_storage/field_sql_storage.install +++ b/core/modules/field/modules/field_sql_storage/field_sql_storage.install @@ -13,7 +13,7 @@ function field_sql_storage_schema() { // Dynamic (data) tables. if (db_table_exists('field_config')) { - $fields = field_read_fields(array(), array('include_deleted' => TRUE, 'include_inactive' => TRUE)); + $fields = field_read_fields(array(), array('include_deleted' => TRUE)); drupal_load('module', 'field_sql_storage'); foreach ($fields as $field) { if ($field['storage']['type'] == 'field_sql_storage') { diff --git a/core/modules/field/modules/field_sql_storage/field_sql_storage.module b/core/modules/field/modules/field_sql_storage/field_sql_storage.module index adc50bd..3cce888 100644 --- a/core/modules/field/modules/field_sql_storage/field_sql_storage.module +++ b/core/modules/field/modules/field_sql_storage/field_sql_storage.module @@ -687,8 +687,8 @@ function field_sql_storage_field_storage_delete_instance($instance) { * Implements hook_field_attach_rename_bundle(). */ function field_sql_storage_field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new) { - // We need to account for deleted or inactive fields and instances. - $instances = field_read_instances(array('entity_type' => $entity_type, 'bundle' => $bundle_new), array('include_deleted' => TRUE, 'include_inactive' => TRUE)); + // We need to account for deleted fields and instances. + $instances = field_read_instances(array('entity_type' => $entity_type, 'bundle' => $bundle_new), array('include_deleted' => TRUE)); foreach ($instances as $instance) { $field = field_info_field_by_id($instance['field_id']); if ($field['storage']['type'] == 'field_sql_storage') { diff --git a/core/modules/field/tests/field.test b/core/modules/field/tests/field.test index 3566484..11e46a7 100644 --- a/core/modules/field/tests/field.test +++ b/core/modules/field/tests/field.test @@ -1102,7 +1102,6 @@ class FieldInfoTestCase extends FieldTestCase { $this->assertEqual($fields[$field['field_name']]['settings'][$key], $val, t("Field setting $key has correct default value $val")); } $this->assertEqual($fields[$field['field_name']]['cardinality'], 1, t('info fields contains cardinality 1')); - $this->assertEqual($fields[$field['field_name']]['active'], 1, t('info fields contains active 1')); // Create an instance, verify that it shows up $instance = array( @@ -2380,69 +2379,6 @@ class FieldCrudTestCase extends FieldTestCase { $this->pass(t("An unchangeable setting cannot be updated.")); } } - - /** - * Test that fields are properly marked active or inactive. - */ - function testActive() { - $field_definition = array( - 'field_name' => 'field_1', - 'type' => 'test_field', - // For this test, we need a storage backend provided by a different - // module than field_test.module. - 'storage' => array( - 'type' => 'field_sql_storage', - ), - ); - field_create_field($field_definition); - - // Test disabling and enabling: - // - the field type module, - // - the storage module, - // - both. - $this->_testActiveHelper($field_definition, array('field_test')); - $this->_testActiveHelper($field_definition, array('field_sql_storage')); - $this->_testActiveHelper($field_definition, array('field_test', 'field_sql_storage')); - } - - /** - * Helper function for testActive(). - * - * Test dependency between a field and a set of modules. - * - * @param $field_definition - * A field definition. - * @param $modules - * An aray of module names. The field will be tested to be inactive as long - * as any of those modules is disabled. - */ - function _testActiveHelper($field_definition, $modules) { - $field_name = $field_definition['field_name']; - - // Read the field. - $field = field_read_field($field_name); - $this->assertTrue($field_definition <= $field, t('The field was properly read.')); - - module_disable($modules, FALSE); - - $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.')); - - // Re-enable modules one by one, and check that the field is still inactive - // while some modules remain disabled. - while ($modules) { - $field = field_read_field($field_name); - $this->assertTrue(empty($field), t('%modules disabled. The field is marked inactive.', array('%modules' => implode(', ', $modules)))); - - $module = array_shift($modules); - module_enable(array($module), FALSE); - } - - // Check that the field is active again after all modules have been - // enabled. - $field = field_read_field($field_name); - $this->assertTrue($field_definition <= $field, t('The field was was marked active.')); - } } class FieldInstanceCrudTestCase extends FieldTestCase { @@ -3178,7 +3114,7 @@ class FieldBulkDeleteTestCase extends FieldTestCase { field_delete_instance($instance); // The instance still exists, deleted. - $instances = field_read_instances(array('field_id' => $field['id'], 'deleted' => 1), array('include_deleted' => 1, 'include_inactive' => 1)); + $instances = field_read_instances(array('field_id' => $field['id'], 'deleted' => 1), array('include_deleted' => 1)); $this->assertEqual(count($instances), 1, 'There is one deleted instance'); $this->assertEqual($instances[0]['bundle'], $bundle, 'The deleted instance is for the correct bundle'); @@ -3256,18 +3192,18 @@ class FieldBulkDeleteTestCase extends FieldTestCase { $this->checkHooksInvocations($hooks, $actual_hooks); // The instance still exists, deleted. - $instances = field_read_instances(array('field_id' => $field['id'], 'deleted' => 1), array('include_deleted' => 1, 'include_inactive' => 1)); + $instances = field_read_instances(array('field_id' => $field['id'], 'deleted' => 1), array('include_deleted' => 1)); $this->assertEqual(count($instances), 1, 'There is one deleted instance'); // Purge the instance. field_purge_batch($batch_size); // The instance is gone. - $instances = field_read_instances(array('field_id' => $field['id'], 'deleted' => 1), array('include_deleted' => 1, 'include_inactive' => 1)); + $instances = field_read_instances(array('field_id' => $field['id'], 'deleted' => 1), array('include_deleted' => 1)); $this->assertEqual(count($instances), 0, 'The instance is gone'); // The field still exists, not deleted, because it has a second instance. - $fields = field_read_fields(array('id' => $field['id']), array('include_deleted' => 1, 'include_inactive' => 1)); + $fields = field_read_fields(array('id' => $field['id']), array('include_deleted' => 1); $this->assertTrue(isset($fields[$field['id']]), 'The field exists and is not deleted'); } @@ -3344,7 +3280,7 @@ class FieldBulkDeleteTestCase extends FieldTestCase { field_purge_batch(0); // The field is gone. - $fields = field_read_fields(array('id' => $field['id']), array('include_deleted' => 1, 'include_inactive' => 1)); + $fields = field_read_fields(array('id' => $field['id']), array('include_deleted' => 1)); $this->assertEqual(count($fields), 0, 'The field is purged.'); } } diff --git a/core/modules/field/tests/field_test.storage.inc b/core/modules/field/tests/field_test.storage.inc index a26af17..3c9b251 100644 --- a/core/modules/field/tests/field_test.storage.inc +++ b/core/modules/field/tests/field_test.storage.inc @@ -430,8 +430,8 @@ function field_test_field_attach_create_bundle($bundle) { function field_test_field_attach_rename_bundle($bundle_old, $bundle_new) { $data = _field_test_storage_data(); - // We need to account for deleted or inactive fields and instances. - $instances = field_read_instances(array('bundle' => $bundle_new), array('include_deleted' => TRUE, 'include_inactive' => TRUE)); + // We need to account for deleted fields and instances. + $instances = field_read_instances(array('bundle' => $bundle_new), array('include_deleted' => TRUE)); foreach ($instances as $field_name => $instance) { $field = field_info_field_by_id($instance['field_id']); if ($field['storage']['type'] == 'field_test_storage') { diff --git a/core/modules/field_ui/field_ui.admin.inc b/core/modules/field_ui/field_ui.admin.inc index c22fe21..91d2fa2 100644 --- a/core/modules/field_ui/field_ui.admin.inc +++ b/core/modules/field_ui/field_ui.admin.inc @@ -53,27 +53,6 @@ function field_ui_fields_list() { } /** - * Displays a message listing the inactive fields of a given bundle. - */ -function field_ui_inactive_message($entity_type, $bundle) { - $inactive_instances = field_ui_inactive_instances($entity_type, $bundle); - if (!empty($inactive_instances)) { - $field_types = field_info_field_types(); - $widget_types = field_info_widget_types(); - - foreach ($inactive_instances as $field_name => $instance) { - $list[] = t('%field (@field_name) field requires the %widget_type widget provided by %widget_module module', array( - '%field' => $instance['label'], - '@field_name' => $instance['field_name'], - '%widget_type' => isset($widget_types[$instance['widget']['type']]) ? $widget_types[$instance['widget']['type']]['label'] : $instance['widget']['type'], - '%widget_module' => $instance['widget']['module'], - )); - } - drupal_set_message(t('Inactive fields are not shown unless their providing modules are enabled. The following fields are not enabled: !list', array('!list' => theme('item_list', array('items' => $list)))), 'error'); - } -} - -/** * Determines the rendering order of an array representing a tree. * * Callback for array_reduce() within field_ui_table_pre_render(). @@ -295,7 +274,6 @@ function theme_field_ui_table($variables) { function field_ui_field_overview_form($form, &$form_state, $entity_type, $bundle) { $bundle = field_extract_bundle($entity_type, $bundle); - field_ui_inactive_message($entity_type, $bundle); $admin_path = _field_ui_bundle_admin_path($entity_type, $bundle); // When displaying the form, make sure the list of fields is up-to-date. @@ -729,10 +707,7 @@ function _field_ui_field_overview_form_validate_add_new($form, &$form_state) { function _field_ui_field_name_exists($value) { // Prefix with 'field_'. $field_name = 'field_' . $value; - - // We need to check inactive fields as well, so we can't use - // field_info_fields(). - return (bool) field_read_fields(array('field_name' => $field_name), array('include_inactive' => TRUE)); + return (bool) field_read_fields(array('field_name' => $field_name)); } /** @@ -892,7 +867,6 @@ function field_ui_field_overview_form_submit($form, &$form_state) { function field_ui_display_overview_form($form, &$form_state, $entity_type, $bundle, $view_mode) { $bundle = field_extract_bundle($entity_type, $bundle); - field_ui_inactive_message($entity_type, $bundle); $admin_path = _field_ui_bundle_admin_path($entity_type, $bundle); // Gather type information. diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index c75005a..b5c2e12 100644 --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -324,33 +324,6 @@ function _field_ui_bundle_admin_path($entity_type, $bundle_name) { } /** - * Identifies inactive fields within a bundle. - */ -function field_ui_inactive_instances($entity_type, $bundle_name = NULL) { - if (!empty($bundle_name)) { - $inactive = array($bundle_name => array()); - $params = array('bundle' => $bundle_name); - } - else { - $inactive = array(); - $params = array(); - } - $params['entity_type'] = $entity_type; - - $active_instances = field_info_instances($entity_type); - $all_instances = field_read_instances($params, array('include_inactive' => TRUE)); - foreach ($all_instances as $instance) { - if (!isset($active_instances[$instance['bundle']][$instance['field_name']])) { - $inactive[$instance['bundle']][$instance['field_name']] = $instance; - } - } - if (!empty($bundle_name)) { - return $inactive[$bundle_name]; - } - return $inactive; -} - -/** * Implements hook_form_FORM_ID_alter(). * * Adds a button 'Save and add fields' to the 'Create content type' form.