diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/field/field.crud.inc | 40 | ||||
-rw-r--r-- | modules/field/field.install | 23 | ||||
-rw-r--r-- | modules/field/field.module | 13 | ||||
-rw-r--r-- | modules/field/field.test | 2 |
4 files changed, 25 insertions, 53 deletions
diff --git a/modules/field/field.crud.inc b/modules/field/field.crud.inc index fe5bb282d..d9351cff7 100644 --- a/modules/field/field.crud.inc +++ b/modules/field/field.crud.inc @@ -144,9 +144,6 @@ * edit forms. * - module (string, read-only) * The name of the module that implements the widget type. - * - active (integer, read-only) - * TRUE if the module that implements the widget type is currently - * enabled, FALSE otherwise. * - display (array) * A sub-array of key/value pairs identifying build modes and the way the * field values should be displayed in each build mode. @@ -597,7 +594,7 @@ function field_create_instance($instance) { // Check that the specified field exists. $field = field_read_field($instance['field_name']); if (empty($field)) { - throw new FieldException("Attempt to create an instance of a field that doesn't exist."); + throw new FieldException("Attempt to create an instance of a field that doesn't exist or is currently inactive."); } // Set the field id. @@ -613,12 +610,12 @@ function field_create_instance($instance) { // Those checks should probably happen in _field_write_instance() ? // Problem : this would mean that a UI module cannot update an instance with a disabled formatter. - // Ensure the field instance is unique. - $prior_instance = field_read_instance($instance['field_name'], $instance['bundle'], array('include_inactive' => TRUE)); + // 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['field_name'], $instance['bundle']); if (!empty($prior_instance)) { - $message = $prior_instance['widget']['active']? - t('Attempt to create a field instance %field_name,%bundle which already exists and is active.', array('%field_name' => $instance['field_name'], '%bundle' => $instance['bundle'])): - t('Attempt to create a field instance %field_name,%bundle which already exists, although inactive.', array('%field_name' => $instance['field_name'], '%bundle' => $instance['bundle'])); + $message = t('Attempt to create a field instance that already exists.'); throw new FieldException($message); } @@ -707,11 +704,8 @@ function _field_write_instance($instance, $update = FALSE) { ); // Check widget module. $widget_type = field_info_widget_types($instance['widget']['type']); - $widget_module = $widget_type['module']; - $widget_active = module_exists($widget_module); + $instance['widget']['module'] = $widget_type['module']; $instance['widget']['settings'] += field_info_widget_settings($instance['widget']['type']); - $instance['widget']['module'] = $widget_module; - $instance['widget']['active'] = $widget_active; // Make sure there is at least display info for the 'full' build mode. $instance['display'] += array( @@ -736,15 +730,12 @@ function _field_write_instance($instance, $update = FALSE) { // not have its own column and is not automatically populated when the // instance is read. $data = $instance; - unset($data['id'], $data['field_id'], $data['field_name'], $data['bundle'], $data['widget']['type'], $data['widget']['module'], $data['widget']['active'], $data['deleted']); + unset($data['id'], $data['field_id'], $data['field_name'], $data['bundle'], $data['deleted']); $record = array( 'field_id' => $instance['field_id'], 'field_name' => $instance['field_name'], 'bundle' => $instance['bundle'], - 'widget_type' => $instance['widget']['type'], - 'widget_module' => $widget_module, - 'widget_active' => $widget_active, 'data' => $data, 'deleted' => $instance['deleted'], ); @@ -773,8 +764,9 @@ 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 - * is inactive. Setting - * $include_additional['include_inactive'] to TRUE will override this + * has been deleted, or whose field is inactive. Setting + * $include_additional['include_inactive'] or + * $include_additional['include_deleted'] to TRUE will override this * behavior. * @return * An instance structure, or FALSE. @@ -793,8 +785,8 @@ function field_read_instance($field_name, $bundle, $include_additional = array() * 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 are inactive or have been marked deleted. Setting - * $include_additional['include_inactive'] or + * 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 * behavior. * @return @@ -812,8 +804,7 @@ function field_read_instances($params = array(), $include_additional = array()) if (!isset($include_additional['include_inactive']) || !$include_additional['include_inactive']) { $query ->condition('fc.active', 1) - ->condition('fc.storage_active', 1) - ->condition('fci.widget_active', 1); + ->condition('fc.storage_active', 1); } if (!isset($include_additional['include_deleted']) || !$include_additional['include_deleted']) { $query->condition('fc.deleted', 0); @@ -830,9 +821,6 @@ function field_read_instances($params = array(), $include_additional = array()) $instance['field_name'] = $record['field_name']; $instance['bundle'] = $record['bundle']; $instance['deleted'] = $record['deleted']; - $instance['widget']['type'] = $record['widget_type']; - $instance['widget']['module'] = $record['widget_module']; - $instance['widget']['active'] = $record['widget_active']; module_invoke_all('field_read_instance', $instance); $instances[] = $instance; diff --git a/modules/field/field.install b/modules/field/field.install index c112ef1b6..2ee9daa12 100644 --- a/modules/field/field.install +++ b/modules/field/field.install @@ -124,15 +124,17 @@ function field_schema() { 'not null' => TRUE, 'description' => 'The identifier of the field attached by this instance', ), - 'field_name' => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => ''), - 'bundle' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''), - 'widget_type' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''), - 'widget_module' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''), - 'widget_active' => array( - 'type' => 'int', - 'size' => 'tiny', + 'field_name' => array( + 'type' => 'varchar', + 'length' => 32, 'not null' => TRUE, - 'default' => 0, + 'default' => '' + ), + 'bundle' => array( + 'type' => 'varchar', + 'length' => 128, + 'not null' => TRUE, + 'default' => '' ), 'data' => array( 'type' => 'text', @@ -152,12 +154,7 @@ function field_schema() { // Used by field_delete_instance(). 'field_name_bundle' => array('field_name', 'bundle'), // Used by field_read_instances(). - 'widget_active' => array('widget_active'), 'deleted' => array('deleted'), - // Used by field_modules_disabled(). - 'widget_module' => array('widget_module'), - // Used by field_associate_fields(). - 'widget_type' => array('widget_type'), ), ); $schema['cache_field'] = drupal_get_schema_unprocessed('system', 'cache'); diff --git a/modules/field/field.module b/modules/field/field.module index a4e9e4d12..86bf32283 100644 --- a/modules/field/field.module +++ b/modules/field/field.module @@ -228,10 +228,6 @@ function field_modules_disabled($modules) { ->fields(array('storage_active' => 0)) ->condition('storage_module', $module) ->execute(); - db_update('field_config_instance') - ->fields(array('widget_active' => 0)) - ->condition('widget_module', $module) - ->execute(); field_cache_clear(TRUE); } } @@ -261,15 +257,6 @@ function field_associate_fields($module) { ->condition('storage_type', $name) ->execute(); } - // Associate widget types. - $widget_types = (array) module_invoke($module, 'field_widget_info'); - foreach ($widget_types as $name => $widget_info) { - watchdog('field', 'Updating widget type %type with module %module.', array('%type' => $name, '%module' => $module)); - db_update('field_config_instance') - ->fields(array('widget_module' => $module, 'widget_active' => 1)) - ->condition('widget_type', $name) - ->execute(); - } } /** diff --git a/modules/field/field.test b/modules/field/field.test index 7c1d2da6b..fc0b9899f 100644 --- a/modules/field/field.test +++ b/modules/field/field.test @@ -2012,7 +2012,7 @@ class FieldInstanceCrudTestCase extends FieldTestCase { $this->assertIdentical($record['data']['required'], FALSE, t('Required defaults to false.')); $this->assertIdentical($record['data']['label'], $this->instance_definition['field_name'], t('Label defaults to field name.')); $this->assertIdentical($record['data']['description'], '', t('Description defaults to empty string.')); - $this->assertIdentical($record['widget_type'], $field_type['default_widget'], t('Default widget has been written.')); + $this->assertIdentical($record['data']['widget']['type'], $field_type['default_widget'], t('Default widget has been written.')); $this->assertTrue(isset($record['data']['display']['full']), t('Display for "full" build_mode has been written.')); $this->assertIdentical($record['data']['display']['full']['type'], $field_type['default_formatter'], t('Default formatter for "full" build_mode has been written.')); |