Issue #2032369 by yched: Fixed _update_8003_field_create_field() relies on field schemas never changing and plugins being available.
parent
6daeb3c7f2
commit
dbcb65bd47
|
@ -252,6 +252,34 @@ function block_update_8008() {
|
|||
'entity_types' => array('custom_block'),
|
||||
'module' => 'text',
|
||||
'cardinality' => 1,
|
||||
'schema' => array(
|
||||
'columns' => array(
|
||||
'value' => array(
|
||||
'type' => 'text',
|
||||
'size' => 'big',
|
||||
'not null' => FALSE,
|
||||
),
|
||||
'summary' => array(
|
||||
'type' => 'text',
|
||||
'size' => 'big',
|
||||
'not null' => FALSE,
|
||||
),
|
||||
'format' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
),
|
||||
),
|
||||
'indexes' => array(
|
||||
'format' => array('format'),
|
||||
),
|
||||
'foreign keys' => array(
|
||||
'format' => array(
|
||||
'table' => 'filter_format',
|
||||
'columns' => array('format' => 'format'),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
_update_8003_field_create_field($body_field);
|
||||
|
||||
|
|
|
@ -15,7 +15,12 @@ use Drupal\field\Plugin\Core\Entity\Field;
|
|||
* they get executed after field_update_8003().
|
||||
*
|
||||
* @param array $field_config
|
||||
* An array of field properties.
|
||||
* An array of field properties. Required properties are:
|
||||
* - 'id': The field id (machine name).
|
||||
* - 'type': The field type.
|
||||
* - 'module': The name of the module providing the field type.
|
||||
* - 'schema': The field schema, in the same format as
|
||||
* Drupal\field\Plugin\Type\FieldType\ConfigFieldInterface::schema().
|
||||
*
|
||||
* @ingroup update_api
|
||||
*/
|
||||
|
|
|
@ -153,6 +153,24 @@ class CrudTest extends FieldUnitTestBase {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that an explicit schema can be provided on creation of a field.
|
||||
*
|
||||
* This behavior is needed to allow field creation within updates, since
|
||||
* plugin classes (and thus the field type schema) cannot be accessed.
|
||||
*/
|
||||
function testCreateFieldWithExplicitSchema() {
|
||||
$field_definition = array(
|
||||
'field_name' => 'field_2',
|
||||
'type' => 'test_field',
|
||||
'schema' => array(
|
||||
'dummy' => 'foobar'
|
||||
),
|
||||
);
|
||||
$field = entity_create('field_entity', $field_definition);
|
||||
$this->assertEqual($field->getSchema(), $field_definition['schema']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test failure to create a field.
|
||||
*/
|
||||
|
|
|
@ -665,6 +665,47 @@ function user_update_8011() {
|
|||
'uri_scheme' => 'public',
|
||||
'default_image' => FALSE,
|
||||
),
|
||||
'schema' => array(
|
||||
'columns' => array(
|
||||
'target_id' => array(
|
||||
'description' => 'The ID of the target entity.',
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'unsigned' => TRUE,
|
||||
),
|
||||
'alt' => array(
|
||||
'description' => "Alternative image text, for the image's 'alt' attribute.",
|
||||
'type' => 'varchar',
|
||||
'length' => 512,
|
||||
'not null' => FALSE,
|
||||
),
|
||||
'title' => array(
|
||||
'description' => "Image title text, for the image's 'title' attribute.",
|
||||
'type' => 'varchar',
|
||||
'length' => 1024,
|
||||
'not null' => FALSE,
|
||||
),
|
||||
'width' => array(
|
||||
'description' => 'The width of the image in pixels.',
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
),
|
||||
'height' => array(
|
||||
'description' => 'The height of the image in pixels.',
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
),
|
||||
),
|
||||
'indexes' => array(
|
||||
'target_id' => array('target_id'),
|
||||
),
|
||||
'foreign keys' => array(
|
||||
'target_id' => array(
|
||||
'table' => 'file_managed',
|
||||
'columns' => array('target_id' => 'fid'),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
_update_8003_field_create_field($field);
|
||||
|
||||
|
|
Loading…
Reference in New Issue