diff --git a/core/modules/field/field.install b/core/modules/field/field.install index 6990a91..0fa04fa 100644 --- a/core/modules/field/field.install +++ b/core/modules/field/field.install @@ -54,120 +54,6 @@ function _update_8000_field_create_field(array &$field_config) { } /** - * Deletes a field directly from configuration. - * - * To protect user data, this function can only be used to delete fields once - * all information it stored is gone. Delete all data from the - * field_data_$field_name table before calling by either manually issuing - * delete queries against it or using _update_8000_field_delete_instance(). - * - * @param string $field_name - * The field name to delete. - * - * @ingroup update_api - */ -function _update_8000_field_delete_field($field_name) { - $table_name = 'field_data_' . $field_name; - if (db_select($table_name)->range(0, 1)->countQuery()->execute()->fetchField()) { - $t = get_t(); - throw new Exception($t('This function can only be used to delete fields without data')); - } - // Delete all instances. - $config_names = config_get_storage_names_with_prefix('field.instance'); - foreach ($config_names as $id) { - list(, , $entity_type, $bundle, $config_field_name) = explode('.', $id); - if ($config_field_name == $field_name) { - update_config_remove_config('field.instance', $entity_type . '.' . $bundle . '.' . $field_name); - } - } - - // Nuke field data and revision tables. - db_drop_table($table_name); - db_drop_table('field_revision_' . $field_name); - - // Delete the field. - update_config_remove_config('field.field', $field_name); -} - -/** - * Deletes an instance and all its data of a field stored in configuration. - * - * BEWARE: This function deletes user data from the field storage tables. - * - * @param string $field_name - * The name of the field. - * @param string $entity_type - * The name of the entity type. - * @param $bundle - * The name of the bundle. - * - * @ingroup update_api - */ -function _update_8000_field_delete_instance($field_name, $entity_type, $bundle) { - // Delete field instance configuration data. - update_config_remove_config('field.instance', $entity_type . '.' . $bundle . '.' . $field_name); - - // Nuke data. - db_delete('field_data_' . $field_name) - ->condition('entity_type', $entity_type) - ->condition('bundle', $bundle) - ->execute(); - db_delete('field_revision_' . $field_name) - ->condition('entity_type', $entity_type) - ->condition('bundle', $bundle) - ->execute(); -} - -/** - * Fetches all of the field definitions from configuration. - * - * Warning: Unlike the field_read_fields() API function, this function returns - * all fields by default, including deleted and inactive fields, unless - * specified otherwise in the $conditions parameter. - * - * @param $conditions - * An array of conditions to limit the select query to. - * @param $key - * The name of the field property the return array is indexed by. Using - * anything else than 'id' might cause incomplete results if the $conditions - * do not filter out deleted fields. - * - * @return - * An array of fields matching $conditions, keyed by the property specified - * by the $key parameter. - * @ingroup update_api - */ -function _update_8000_field_read_fields(array $conditions = array(), $key = 'id') { - $matching_fields = array(); - - $config_names = config_get_storage_names_with_prefix('field.field'); - $config_names += Drupal::state()->get('field.field.deleted') ?: array(); - - if (empty($config_names)) { - return array(); - } - - // Collect matching fields. - foreach ($config_names as $field) { - if (!is_array($field)) { - $field = config($field)->get(); - } - - if (!empty($conditions)) { - foreach ($conditions as $key => $value) { - if ($field[$key] != $value) { - continue 2; - } - } - } - - $matching_fields[$field[$key]] = $field; - } - - return $matching_fields; -} - -/** * Writes a field instance directly to configuration. * * @param array $field_config