Issue #1503314 by swentel, amateescu, bojanz: Remove the concept of active / inactive (field types, storage) from Field API.
parent
0432bc8616
commit
160e691c08
|
@ -1200,10 +1200,10 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function onBundleRename($bundle, $bundle_new) {
|
||||
// We need to account for deleted or inactive fields and instances. The
|
||||
// method runs before the instance definitions are updated, so we need to
|
||||
// fetch them using the old bundle name.
|
||||
$instances = field_read_instances(array('entity_type' => $this->entityType, 'bundle' => $bundle), array('include_deleted' => TRUE, 'include_inactive' => TRUE));
|
||||
// We need to account for deleted fields and instances. The method runs
|
||||
// before the instance definitions are updated, so we need to fetch them
|
||||
// using the old bundle name.
|
||||
$instances = field_read_instances(array('entity_type' => $this->entityType, 'bundle' => $bundle), array('include_deleted' => TRUE));
|
||||
foreach ($instances as $instance) {
|
||||
$field = $instance->getField();
|
||||
$table_name = static::_fieldTableName($field);
|
||||
|
|
|
@ -14,11 +14,7 @@ use Drupal\field\Entity\Field;
|
|||
*/
|
||||
function comment_uninstall() {
|
||||
// Remove the comment fields.
|
||||
$fields = entity_load_multiple_by_properties('field_entity', array(
|
||||
'type' => 'comment',
|
||||
'include_inactive' => TRUE,
|
||||
'include_deleted' => FALSE,
|
||||
));
|
||||
$fields = entity_load_multiple_by_properties('field_entity', array('type' => 'comment'));
|
||||
foreach ($fields as $field) {
|
||||
entity_invoke_bundle_hook('delete', 'comment', $field->entity_type . '__' . $field->name);
|
||||
$field->delete();
|
||||
|
|
|
@ -90,9 +90,6 @@ class EmailFieldTest extends WebTestBase {
|
|||
))
|
||||
->save();
|
||||
|
||||
// Rebuild field info to check if email field still working.
|
||||
field_sync_field_status();
|
||||
|
||||
// Display creation form.
|
||||
$this->drupalGet('entity_test/add');
|
||||
$this->assertFieldByName("{$field_name}[0][value]", '', 'Widget found.');
|
||||
|
@ -109,14 +106,13 @@ class EmailFieldTest extends WebTestBase {
|
|||
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
|
||||
$id = $match[1];
|
||||
$this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
|
||||
$this->assertRaw($value);
|
||||
|
||||
if ($this->assertRaw($value)) {
|
||||
// Verify that a mailto link is displayed.
|
||||
$entity = entity_load('entity_test', $id);
|
||||
$display = entity_get_display($entity->entityType(), $entity->bundle(), 'full');
|
||||
$entity->content = field_attach_view($entity, $display);
|
||||
$this->drupalSetContent(drupal_render($entity->content));
|
||||
$this->assertLinkByHref('mailto:test@example.com');
|
||||
}
|
||||
// Verify that a mailto link is displayed.
|
||||
$entity = entity_load('entity_test', $id);
|
||||
$display = entity_get_display($entity->entityType(), $entity->bundle(), 'full');
|
||||
$entity->content = field_attach_view($entity, $display);
|
||||
$this->drupalSetContent(drupal_render($entity->content));
|
||||
$this->assertLinkByHref('mailto:test@example.com');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,9 +69,6 @@ class EntityReferenceFieldDefaultValueTest extends WebTestBase {
|
|||
));
|
||||
$this->instance->save();
|
||||
|
||||
// Rebuild field info to check if entity_reference field still working.
|
||||
field_sync_field_status();
|
||||
|
||||
// Set created node as default_value.
|
||||
$instance_edit = array(
|
||||
'default_value_input[' . $this->field->name . '][0][target_id]' => $referenced_node->getTitle() . ' (' .$referenced_node->id() . ')',
|
||||
|
|
|
@ -35,9 +35,6 @@ field.field.*.*:
|
|||
module:
|
||||
type: string
|
||||
label: 'Module'
|
||||
active:
|
||||
type: boolean
|
||||
label: 'Active'
|
||||
locked:
|
||||
type: boolean
|
||||
label: 'Locked'
|
||||
|
|
|
@ -160,7 +160,7 @@ function field_info_formatter_settings($type) {
|
|||
/**
|
||||
* Returns a lightweight map of fields across bundles.
|
||||
*
|
||||
* The function only returns active, non deleted fields.
|
||||
* The function only returns non-deleted fields.
|
||||
*
|
||||
* @return
|
||||
* An array keyed by entity type. Each value is an array which keys are
|
||||
|
@ -195,9 +195,7 @@ function field_info_field_map() {
|
|||
* The entity type.
|
||||
* @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
|
||||
|
@ -218,8 +216,7 @@ function field_info_field($entity_type, $field_name) {
|
|||
* Returns data about an individual field, given a field ID.
|
||||
*
|
||||
* @param $field_id
|
||||
* The ID of the field to retrieve. $field_id can refer to a deleted field,
|
||||
* but not an inactive one.
|
||||
* The ID of the field to retrieve. $field_id can refer to a deleted field.
|
||||
*
|
||||
* @return
|
||||
* The field array, as returned by field_read_fields(), with an additional
|
||||
|
@ -342,9 +339,7 @@ function field_info_instance($entity_type, $field_name, $bundle_name) {
|
|||
* @param $field_name
|
||||
* 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 behavior.
|
||||
* Additional properties to match.
|
||||
*
|
||||
* @return
|
||||
* A field definition array, or FALSE.
|
||||
|
@ -361,13 +356,12 @@ function field_read_field($entity_type, $field_name, $include_additional = array
|
|||
* Reads in fields that match an array of conditions.
|
||||
*
|
||||
* @param array $conditions
|
||||
* An array of conditions to match against. Keys are names of properties found
|
||||
* in field configuration files, and values are conditions to match.
|
||||
* An array of conditions to match against. Keys are names of properties
|
||||
* found in field configuration files, and values are conditions to match.
|
||||
* @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.
|
||||
* The default behavior of this function is to not return fields that have
|
||||
* been deleted. Setting $include_additional['include_deleted'] to TRUE will
|
||||
* override this behavior.
|
||||
*
|
||||
* @return
|
||||
* An array of fields matching $params. If
|
||||
|
@ -378,14 +372,11 @@ function field_read_field($entity_type, $field_name, $include_additional = array
|
|||
* entity_load_multiple_by_properties('field_entity', $conditions).
|
||||
*/
|
||||
function field_read_fields($conditions = array(), $include_additional = array()) {
|
||||
// Include inactive fields if specified in the $include_additional parameter.
|
||||
$include_inactive = isset($include_additional['include_inactive']) && $include_additional['include_inactive'];
|
||||
// Include deleted fields if specified either in the $include_additional or
|
||||
// the $conditions parameters.
|
||||
$include_deleted = (isset($include_additional['include_deleted']) && $include_additional['include_deleted']) || (isset($conditions['deleted']) && $conditions['deleted']);
|
||||
|
||||
// Pass include_inactive and include_deleted to the $conditions array.
|
||||
$conditions['include_inactive'] = $include_inactive;
|
||||
// Pass include_deleted to the $conditions array.
|
||||
$conditions['include_deleted'] = $include_deleted;
|
||||
|
||||
return entity_load_multiple_by_properties('field_entity', $conditions);
|
||||
|
@ -406,9 +397,8 @@ function field_read_fields($conditions = array(), $include_additional = array())
|
|||
* 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.
|
||||
* been deleted. Setting $include_additional['include_deleted'] to TRUE will
|
||||
* override this behavior.
|
||||
*
|
||||
* @return
|
||||
* An instance structure, or FALSE.
|
||||
|
@ -430,8 +420,7 @@ function field_read_instance($entity_type, $field_name, $bundle, $include_additi
|
|||
* conditions to match.
|
||||
* @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
|
||||
* have been marked deleted. Setting
|
||||
* $include_additional['include_deleted'] to TRUE will override this behavior.
|
||||
*
|
||||
* @return
|
||||
|
@ -441,15 +430,11 @@ function field_read_instance($entity_type, $field_name, $bundle, $include_additi
|
|||
* entity_load_multiple_by_properties('field_instance', $conditions).
|
||||
*/
|
||||
function field_read_instances($conditions = array(), $include_additional = array()) {
|
||||
// Include instances of inactive fields if specified in the
|
||||
// $include_additional parameter.
|
||||
$include_inactive = isset($include_additional['include_inactive']) && $include_additional['include_inactive'];
|
||||
// Include deleted instances if specified either in the $include_additional
|
||||
// or the $conditions parameters.
|
||||
$include_deleted = (isset($include_additional['include_deleted']) && $include_additional['include_deleted']) || (isset($conditions['deleted']) && $conditions['deleted']);
|
||||
|
||||
// Pass include_inactive and include_deleted to the $conditions array.
|
||||
$conditions['include_inactive'] = $include_inactive;
|
||||
// Pass include_deleted to the $conditions array.
|
||||
$conditions['include_deleted'] = $include_deleted;
|
||||
|
||||
return entity_load_multiple_by_properties('field_instance', $conditions);
|
||||
|
|
|
@ -38,6 +38,7 @@ function field_info_cache_clear() {
|
|||
// Clear typed data definitions.
|
||||
\Drupal::typedData()->clearCachedDefinitions();
|
||||
\Drupal::service('plugin.manager.field.field_type')->clearCachedDefinitions();
|
||||
\Drupal::service('config.factory')->reset();
|
||||
|
||||
Field::fieldInfo()->flush();
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ function _update_8003_field_create_field(array &$field_config) {
|
|||
'locked' => FALSE,
|
||||
'settings' => array(),
|
||||
'indexes' => array(),
|
||||
'active' => TRUE,
|
||||
'status' => 1,
|
||||
'langcode' => 'und',
|
||||
);
|
||||
|
@ -337,7 +336,6 @@ function field_update_8003() {
|
|||
'uuid' => $uuid->generate(),
|
||||
'type' => $record['type'],
|
||||
'module' => $record['module'],
|
||||
'active' => $record['active'],
|
||||
'entity_type' => $record['entity_type'],
|
||||
'settings' => $record['data']['settings'],
|
||||
'locked' => $record['locked'],
|
||||
|
|
|
@ -141,9 +141,6 @@ 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 = \Drupal::config('field.settings')->get('purge_batch_size');
|
||||
field_purge_batch($limit);
|
||||
|
@ -254,7 +251,7 @@ function field_entity_bundle_delete($entity_type, $bundle) {
|
|||
// Get the instances on the bundle. 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' => TRUE));
|
||||
$instances = field_read_instances(array('entity_type' => $entity_type, 'bundle' => $bundle));
|
||||
foreach ($instances as $instance) {
|
||||
$instance->delete();
|
||||
}
|
||||
|
@ -267,79 +264,20 @@ function field_entity_bundle_delete($entity_type, $bundle) {
|
|||
* Implements hook_rebuild().
|
||||
*/
|
||||
function field_rebuild() {
|
||||
// Refresh the 'active' status of fields.
|
||||
field_sync_field_status();
|
||||
field_cache_clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_modules_installed().
|
||||
*/
|
||||
function field_modules_installed($modules) {
|
||||
// Refresh the 'active' status of fields.
|
||||
field_sync_field_status();
|
||||
field_cache_clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_modules_uninstalled().
|
||||
*/
|
||||
function field_modules_uninstalled($modules) {
|
||||
// Refresh the 'active' status of fields.
|
||||
field_sync_field_status();
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes the 'active' and 'storage[active]' values for fields.
|
||||
*/
|
||||
function field_sync_field_status() {
|
||||
$module_handler = \Drupal::moduleHandler();
|
||||
$state = \Drupal::state();
|
||||
|
||||
// Get both deleted and non-deleted field definitions.
|
||||
$fields = array();
|
||||
foreach (config_get_storage_names_with_prefix('field.field.') as $name) {
|
||||
$field = \Drupal::config($name)->get();
|
||||
$fields[$field['uuid']] = $field;
|
||||
}
|
||||
$deleted_fields = $state->get('field.field.deleted') ?: array();
|
||||
$fields += $deleted_fields;
|
||||
|
||||
if (empty($fields)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the 'module' and 'active' values for the current set of enabled
|
||||
// modules.
|
||||
$changed = array();
|
||||
$modules = $module_handler->getModuleList();
|
||||
$field_types = \Drupal::service('plugin.manager.field.field_type')->getDefinitions();
|
||||
// Set fields with missing field type modules to inactive.
|
||||
foreach ($fields as $uuid => &$field) {
|
||||
// Associate field types.
|
||||
if (isset($field_types[$field['type']]) && ($field['module'] != $field_types[$field['type']]['provider'] || !$field['active'])) {
|
||||
$field['module'] = $field_types[$field['type']]['provider'];
|
||||
$field['active'] = TRUE;
|
||||
$changed[$uuid] = $field;
|
||||
}
|
||||
if (!isset($modules[$field['module']]) && $field['active']) {
|
||||
$field['active'] = FALSE;
|
||||
$changed[$uuid] = $field;
|
||||
}
|
||||
}
|
||||
|
||||
// Store the updated field definitions.
|
||||
foreach ($changed as $uuid => $field) {
|
||||
if (!empty($field['deleted'])) {
|
||||
$deleted_fields[$uuid] = $field;
|
||||
}
|
||||
else {
|
||||
\Drupal::config('field.field.' . $field['id'])
|
||||
->set('module', $field['module'])
|
||||
->set('active', $field['active'])
|
||||
->save();
|
||||
}
|
||||
}
|
||||
$state->set('field.field.deleted', $deleted_fields);
|
||||
|
||||
field_cache_clear();
|
||||
}
|
||||
|
||||
|
|
|
@ -100,13 +100,6 @@ class Field extends ConfigEntityBase implements FieldInterface {
|
|||
*/
|
||||
public $module;
|
||||
|
||||
/**
|
||||
* Flag indicating whether the field type module is enabled.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $active;
|
||||
|
||||
/**
|
||||
* Field-type specific settings.
|
||||
*
|
||||
|
@ -265,7 +258,6 @@ class Field extends ConfigEntityBase implements FieldInterface {
|
|||
'type',
|
||||
'settings',
|
||||
'module',
|
||||
'active',
|
||||
'locked',
|
||||
'cardinality',
|
||||
'translatable',
|
||||
|
@ -326,9 +318,7 @@ class Field extends ConfigEntityBase implements FieldInterface {
|
|||
|
||||
// Ensure the field name is unique (we do not care about deleted fields).
|
||||
if ($prior_field = $storage_controller->load($this->id)) {
|
||||
$message = $prior_field->active ?
|
||||
'Attempt to create field name %name which already exists and is active.' :
|
||||
'Attempt to create field name %name which already exists, although it is inactive.';
|
||||
$message = 'Attempt to create field name %name which already exists.';
|
||||
throw new FieldException(format_string($message, array('%name' => $this->name)));
|
||||
}
|
||||
|
||||
|
@ -347,7 +337,6 @@ class Field extends ConfigEntityBase implements FieldInterface {
|
|||
throw new FieldException(format_string('Attempt to create a field of unknown type %type.', array('%type' => $this->type)));
|
||||
}
|
||||
$this->module = $field_type['provider'];
|
||||
$this->active = TRUE;
|
||||
|
||||
// Make sure all settings are present, so that a complete field
|
||||
// definition is passed to the various hooks and written to config.
|
||||
|
|
|
@ -250,10 +250,6 @@ class FieldInstance extends ConfigEntityBase implements FieldInstanceInterface {
|
|||
}
|
||||
elseif (isset($values['field_uuid'])) {
|
||||
$field = field_info_field_by_id($values['field_uuid']);
|
||||
// field_info_field_by_id() will not find the field if it is inactive.
|
||||
if (!$field) {
|
||||
$field = current(field_read_fields(array('uuid' => $values['field_uuid']), array('include_inactive' => TRUE, 'include_deleted' => TRUE)));
|
||||
}
|
||||
if (!$field) {
|
||||
throw new FieldException(format_string('Attempt to create an instance of unknown field @uuid', array('@uuid' => $values['field_uuid'])));
|
||||
}
|
||||
|
|
|
@ -190,12 +190,10 @@ class FieldInfo {
|
|||
|
||||
$map = array();
|
||||
|
||||
// Get active fields.
|
||||
// Get fields.
|
||||
foreach (config_get_storage_names_with_prefix('field.field.') as $config_id) {
|
||||
$field_config = $this->config->get($config_id)->get();
|
||||
if ($field_config['active']) {
|
||||
$fields[$field_config['uuid']] = $field_config;
|
||||
}
|
||||
$fields[$field_config['uuid']] = $field_config;
|
||||
}
|
||||
// Get field instances.
|
||||
foreach (config_get_storage_names_with_prefix('field.instance.') as $config_id) {
|
||||
|
@ -216,7 +214,7 @@ class FieldInfo {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns all active fields, including deleted ones.
|
||||
* Returns all fields, including deleted ones.
|
||||
*
|
||||
* @return \Drupal\field\FieldInterface[]
|
||||
* An array of field entities, keyed by field ID.
|
||||
|
@ -254,7 +252,7 @@ class FieldInfo {
|
|||
}
|
||||
|
||||
/**
|
||||
* Retrieves all active, non-deleted instances definitions.
|
||||
* Retrieves all non-deleted instances definitions.
|
||||
*
|
||||
* @param string $entity_type
|
||||
* (optional) The entity type.
|
||||
|
@ -302,7 +300,7 @@ class FieldInfo {
|
|||
/**
|
||||
* Returns a field definition from a field name.
|
||||
*
|
||||
* This method only retrieves active, non-deleted fields.
|
||||
* This method only retrieves non-deleted fields.
|
||||
*
|
||||
* @param string $entity_type
|
||||
* The entity type.
|
||||
|
@ -342,8 +340,6 @@ class FieldInfo {
|
|||
/**
|
||||
* Returns a field entity from a field ID.
|
||||
*
|
||||
* This method only retrieves active fields, deleted or not.
|
||||
*
|
||||
* @param string $field_id
|
||||
* The field ID.
|
||||
*
|
||||
|
@ -444,8 +440,8 @@ class FieldInfo {
|
|||
if (entity_get_info($entity_type) && !empty($field_map[$entity_type])) {
|
||||
|
||||
// Collect names of fields and instances involved in the bundle, using the
|
||||
// field map. The field map is already filtered to active, non-deleted
|
||||
// fields and instances, so those are kept out of the persistent caches.
|
||||
// field map. The field map is already filtered to non-deleted fields and
|
||||
// instances, so those are kept out of the persistent caches.
|
||||
$config_ids = array();
|
||||
foreach ($field_map[$entity_type] as $field_name => $field_data) {
|
||||
if (in_array($bundle, $field_data['bundles'])) {
|
||||
|
|
|
@ -112,10 +112,6 @@ class FieldInstanceStorageController extends ConfigStorageController {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function loadByProperties(array $conditions = array()) {
|
||||
// Include instances of inactive fields if specified in the
|
||||
// $conditions parameters.
|
||||
$include_inactive = isset($conditions['include_inactive']) ? $conditions['include_inactive'] : FALSE;
|
||||
unset($conditions['include_inactive']);
|
||||
// Include deleted instances if specified in the $conditions parameters.
|
||||
$include_deleted = isset($conditions['include_deleted']) ? $conditions['include_deleted'] : FALSE;
|
||||
unset($conditions['include_deleted']);
|
||||
|
@ -139,19 +135,9 @@ class FieldInstanceStorageController extends ConfigStorageController {
|
|||
}
|
||||
}
|
||||
|
||||
// Translate "do not include inactive fields" into actual conditions.
|
||||
if (!$include_inactive) {
|
||||
$conditions['field.active'] = TRUE;
|
||||
}
|
||||
|
||||
// Collect matching instances.
|
||||
$matching_instances = array();
|
||||
foreach ($instances as $instance) {
|
||||
// Only include instances on unknown entity types if 'include_inactive'.
|
||||
if (!$include_inactive && !$this->entityManager->getDefinition($instance->entity_type)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Some conditions are checked against the field.
|
||||
$field = $instance->getField();
|
||||
|
||||
|
@ -163,10 +149,6 @@ class FieldInstanceStorageController extends ConfigStorageController {
|
|||
$checked_value = $field->name;
|
||||
break;
|
||||
|
||||
case 'field.active':
|
||||
$checked_value = $field->active;
|
||||
break;
|
||||
|
||||
case 'field_id':
|
||||
$checked_value = $instance->field_uuid;
|
||||
break;
|
||||
|
|
|
@ -94,10 +94,6 @@ class FieldStorageController extends ConfigStorageController {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function loadByProperties(array $conditions = array()) {
|
||||
// Include instances of inactive fields if specified in the
|
||||
// $conditions parameters.
|
||||
$include_inactive = isset($conditions['include_inactive']) ? $conditions['include_inactive'] : FALSE;
|
||||
unset($conditions['include_inactive']);
|
||||
// Include deleted instances if specified in the $conditions parameters.
|
||||
$include_deleted = isset($conditions['include_deleted']) ? $conditions['include_deleted'] : FALSE;
|
||||
unset($conditions['include_deleted']);
|
||||
|
@ -121,11 +117,6 @@ class FieldStorageController extends ConfigStorageController {
|
|||
}
|
||||
}
|
||||
|
||||
// Translate "do not include inactive instances" into actual conditions.
|
||||
if (!$include_inactive) {
|
||||
$conditions['active'] = TRUE;
|
||||
}
|
||||
|
||||
// Collect matching fields.
|
||||
$matching_fields = array();
|
||||
foreach ($fields as $field) {
|
||||
|
|
|
@ -180,7 +180,7 @@ class BulkDeleteTest extends FieldUnitTestBase {
|
|||
$instance->delete();
|
||||
|
||||
// The instance still exists, deleted.
|
||||
$instances = field_read_instances(array('field_id' => $field->uuid, 'deleted' => TRUE), array('include_deleted' => TRUE, 'include_inactive' => TRUE));
|
||||
$instances = field_read_instances(array('field_id' => $field->uuid, 'deleted' => TRUE), array('include_deleted' => TRUE));
|
||||
$this->assertEqual(count($instances), 1, 'There is one deleted instance');
|
||||
$instance = $instances[0];
|
||||
$this->assertEqual($instance->bundle, $bundle, 'The deleted instance is for the correct bundle');
|
||||
|
@ -258,18 +258,18 @@ class BulkDeleteTest extends FieldUnitTestBase {
|
|||
$this->checkHooksInvocations($hooks, $actual_hooks);
|
||||
|
||||
// The instance still exists, deleted.
|
||||
$instances = field_read_instances(array('field_id' => $field->uuid, 'deleted' => TRUE), array('include_deleted' => TRUE, 'include_inactive' => TRUE));
|
||||
$instances = field_read_instances(array('field_id' => $field->uuid, 'deleted' => TRUE), array('include_deleted' => TRUE));
|
||||
$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->uuid, 'deleted' => TRUE), array('include_deleted' => TRUE, 'include_inactive' => TRUE));
|
||||
$instances = field_read_instances(array('field_id' => $field->uuid, 'deleted' => TRUE), array('include_deleted' => TRUE));
|
||||
$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('uuid' => $field->uuid), array('include_deleted' => TRUE, 'include_inactive' => TRUE));
|
||||
$fields = field_read_fields(array('uuid' => $field->uuid), array('include_deleted' => TRUE));
|
||||
$this->assertTrue(isset($fields[$field->uuid]), 'The field exists and is not deleted');
|
||||
}
|
||||
|
||||
|
@ -342,7 +342,7 @@ class BulkDeleteTest extends FieldUnitTestBase {
|
|||
field_purge_batch(0);
|
||||
|
||||
// The field is gone.
|
||||
$fields = field_read_fields(array('uuid' => $field->uuid), array('include_deleted' => TRUE, 'include_inactive' => TRUE));
|
||||
$fields = field_read_fields(array('uuid' => $field->uuid), array('include_deleted' => TRUE));
|
||||
$this->assertEqual(count($fields), 0, 'The field is purged.');
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,6 @@ class FieldInfoTest extends FieldUnitTestBase {
|
|||
$this->assertEqual($fields[$field->uuid]->getFieldSetting($key), $val, format_string('Field setting %key has correct default value %value', array('%key' => $key, '%value' => $val)));
|
||||
}
|
||||
$this->assertEqual($fields[$field->uuid]->getFieldCardinality(), 1, 'info fields contains cardinality 1');
|
||||
$this->assertEqual($fields[$field->uuid]->active, TRUE, 'info fields contains active 1');
|
||||
|
||||
// Create an instance, verify that it shows up
|
||||
$instance_definition = array(
|
||||
|
|
|
@ -6,7 +6,6 @@ type: text
|
|||
settings:
|
||||
max_length: '255'
|
||||
module: text
|
||||
active: '1'
|
||||
locked: '0'
|
||||
cardinality: '1'
|
||||
translatable: false
|
||||
|
|
|
@ -6,7 +6,6 @@ type: text
|
|||
settings:
|
||||
max_length: '255'
|
||||
module: text
|
||||
active: '1'
|
||||
locked: '0'
|
||||
cardinality: '1'
|
||||
translatable: false
|
||||
|
|
|
@ -7,7 +7,6 @@ type: text
|
|||
settings:
|
||||
max_length: '255'
|
||||
module: text
|
||||
active: '1'
|
||||
locked: '0'
|
||||
cardinality: '1'
|
||||
translatable: '0'
|
||||
|
|
|
@ -7,7 +7,6 @@ type: text
|
|||
settings:
|
||||
max_length: '255'
|
||||
module: text
|
||||
active: '1'
|
||||
locked: '0'
|
||||
cardinality: '1'
|
||||
translatable: '0'
|
||||
|
|
|
@ -544,9 +544,7 @@ class FieldOverview extends OverviewBase {
|
|||
// 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('entity_type' => $this->entity_type, 'name' => $field_name), array('include_inactive' => TRUE));
|
||||
return (bool) field_info_field($this->entity_type, $field_name);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -146,7 +146,6 @@ class FieldEditForm extends FormBase {
|
|||
$form['field']['field_name'] = array('#type' => 'value', '#value' => $field->getFieldName());
|
||||
$form['field']['type'] = array('#type' => 'value', '#value' => $field->getFieldType());
|
||||
$form['field']['module'] = array('#type' => 'value', '#value' => $field->module);
|
||||
$form['field']['active'] = array('#type' => 'value', '#value' => $field->active);
|
||||
|
||||
// Add settings provided by the field module. The field module is
|
||||
// responsible for not returning settings that cannot be changed if
|
||||
|
|
|
@ -10,7 +10,6 @@ settings:
|
|||
- ''
|
||||
allowed_values_function: ''
|
||||
module: options
|
||||
active: '1'
|
||||
entity_type: taxonomy_term
|
||||
locked: '1'
|
||||
cardinality: '1'
|
||||
|
|
|
@ -21,7 +21,7 @@ function forum_install() {
|
|||
// Create the 'taxonomy_forums' field if it doesn't already exist. If forum
|
||||
// is being enabled at the same time as taxonomy after both modules have been
|
||||
// enabled, the field might exist but still be marked inactive.
|
||||
if (!field_read_field('node', 'taxonomy_forums', array('include_inactive' => TRUE))) {
|
||||
if (!field_info_field('node', 'taxonomy_forums')) {
|
||||
entity_create('field_entity', array(
|
||||
'name' => 'taxonomy_forums',
|
||||
'entity_type' => 'node',
|
||||
|
@ -81,7 +81,6 @@ function forum_install() {
|
|||
$fields = entity_load_multiple_by_properties('field_entity', array(
|
||||
'type' => 'comment',
|
||||
'name' => 'comment_forum',
|
||||
'include_inactive' => TRUE,
|
||||
'include_deleted' => FALSE,
|
||||
));
|
||||
if (empty($fields)) {
|
||||
|
|
|
@ -4,7 +4,6 @@ name: field_image
|
|||
entity_type: node
|
||||
type: image
|
||||
module: image
|
||||
active: '1'
|
||||
settings:
|
||||
uri_scheme: public
|
||||
default_image:
|
||||
|
|
|
@ -4,7 +4,6 @@ name: field_tags
|
|||
entity_type: node
|
||||
type: taxonomy_term_reference
|
||||
module: taxonomy
|
||||
active: '1'
|
||||
settings:
|
||||
allowed_values:
|
||||
-
|
||||
|
|
Loading…
Reference in New Issue