Issue #2262975 by Berdir: Fixed Non-Multiple field types with per-field storage are not supported in CckFieldValues.
parent
da1333318a
commit
4e681e62e4
|
@ -117,18 +117,49 @@ class CckFieldValues extends DrupalSqlBase implements SourceEntityInterface {
|
||||||
|
|
||||||
// Handle fields that have their own table.
|
// Handle fields that have their own table.
|
||||||
foreach ($this->getSourceFieldInfo($bundle) as $field_name => $field_info) {
|
foreach ($this->getSourceFieldInfo($bundle) as $field_name => $field_info) {
|
||||||
if ($field_info['multiple'] && !$field_info['db_storage']) {
|
if ($field_info['multiple'] || !$field_info['db_storage']) {
|
||||||
// Select the data.
|
// Select the data.
|
||||||
$table = "content_$field_name";
|
$table = "content_$field_name";
|
||||||
$data = $this
|
$field_query = $this
|
||||||
->select($table, 't')
|
->select($table, 't')
|
||||||
->fields('t', array('delta') + $field_info['columns'])
|
->condition('vid', $row->getSourceProperty('vid'));
|
||||||
->condition('vid', $row->getSourceProperty('vid'))
|
if ($field_info['multiple']) {
|
||||||
->execute()
|
$field_query->addField('t', 'delta');
|
||||||
->fetchAllKeyed();
|
}
|
||||||
|
$data = FALSE;
|
||||||
|
foreach ($field_info['columns'] as $display_name => $column_name) {
|
||||||
|
// The database API won't allow colons in column aliases, so we
|
||||||
|
// will accept the default alias, and fix up the field names later.
|
||||||
|
// Remember how to translate the field names.
|
||||||
|
if ($field_info['type'] == 'filefield' &&
|
||||||
|
(strpos($display_name, ':list') || strpos($display_name, ':description'))) {
|
||||||
|
if (!$data) {
|
||||||
|
//$this->fileDataFields[] = $field_name . '_data';
|
||||||
|
$field_query->addField('t', $field_name . '_data');
|
||||||
|
$data = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$field_query->addField('t', $column_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Set it on the row.
|
if ($field_info['multiple']) {
|
||||||
$row->setSourceProperty($field_name, $data);
|
foreach ($field_query->execute() as $field_row) {
|
||||||
|
foreach ($field_info['columns'] as $display_name => $column_name) {
|
||||||
|
list ( , $column) = explode(':', $display_name);
|
||||||
|
$propery_path = $field_name . '.' . $field_row['delta'] . '.' . $column;
|
||||||
|
$row->setSourceProperty($propery_path, $field_row[$column_name]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ($field_row = $field_query->execute()->fetchAssoc()) {
|
||||||
|
foreach ($field_info['columns'] as $display_name => $column_name) {
|
||||||
|
$row->setSourceProperty(str_replace(':', '.', $display_name), $field_row[$column_name]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parent::prepareRow($row);
|
parent::prepareRow($row);
|
||||||
|
|
|
@ -139,7 +139,7 @@ class Drupal6FieldInstance extends Drupal6DumpBase {
|
||||||
))
|
))
|
||||||
->values(array(
|
->values(array(
|
||||||
'field_name' => 'field_test',
|
'field_name' => 'field_test',
|
||||||
'type_name' => 'article',
|
'type_name' => 'test_page',
|
||||||
'weight' => 1,
|
'weight' => 1,
|
||||||
'label' => 'Text Field',
|
'label' => 'Text Field',
|
||||||
'widget_type' => 'text_textfield',
|
'widget_type' => 'text_textfield',
|
||||||
|
@ -630,7 +630,7 @@ class Drupal6FieldInstance extends Drupal6DumpBase {
|
||||||
|
|
||||||
// Create the field table.
|
// Create the field table.
|
||||||
$this->createTable('content_node_field', array(
|
$this->createTable('content_node_field', array(
|
||||||
'description' => 'Table that contains field instance settings.',
|
'description' => 'Table that contains field settings.',
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'field_name' => array(
|
'field_name' => array(
|
||||||
'type' => 'varchar',
|
'type' => 'varchar',
|
||||||
|
@ -712,7 +712,7 @@ class Drupal6FieldInstance extends Drupal6DumpBase {
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'global_settings' => 'a:4:{s:15:"text_processing";s:1:"1";s:10:"max_length";s:0:"";s:14:"allowed_values";s:0:"";s:18:"allowed_values_php";s:0:"";}',
|
'global_settings' => 'a:4:{s:15:"text_processing";s:1:"1";s:10:"max_length";s:0:"";s:14:"allowed_values";s:0:"";s:18:"allowed_values_php";s:0:"";}',
|
||||||
'multiple' => 0,
|
'multiple' => 0,
|
||||||
'db_storage' => 1,
|
'db_storage' => 0,
|
||||||
'db_columns' => serialize(array(
|
'db_columns' => serialize(array(
|
||||||
'value' => array(
|
'value' => array(
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
|
@ -721,6 +721,12 @@ class Drupal6FieldInstance extends Drupal6DumpBase {
|
||||||
'sortable' => TRUE,
|
'sortable' => TRUE,
|
||||||
'views' => TRUE,
|
'views' => TRUE,
|
||||||
),
|
),
|
||||||
|
'format' => array(
|
||||||
|
'type' => 'int',
|
||||||
|
'unsigned' => TRUE,
|
||||||
|
'not null' => TRUE,
|
||||||
|
'default' => 0,
|
||||||
|
),
|
||||||
)),
|
)),
|
||||||
'active' => 1,
|
'active' => 1,
|
||||||
))
|
))
|
||||||
|
@ -741,7 +747,16 @@ class Drupal6FieldInstance extends Drupal6DumpBase {
|
||||||
'global_settings' => '',
|
'global_settings' => '',
|
||||||
'multiple' => 0,
|
'multiple' => 0,
|
||||||
'db_storage' => 1,
|
'db_storage' => 1,
|
||||||
'db_columns' => 'a:0:{}',
|
'db_columns' => serialize(array(
|
||||||
|
'value' => array(
|
||||||
|
'type' => 'numeric',
|
||||||
|
'precision' => 10,
|
||||||
|
'scale' => 2,
|
||||||
|
'not null' => FALSE,
|
||||||
|
'sortable' => TRUE,
|
||||||
|
'views' => TRUE,
|
||||||
|
),
|
||||||
|
)),
|
||||||
'active' => 1,
|
'active' => 1,
|
||||||
))
|
))
|
||||||
->values(array(
|
->values(array(
|
||||||
|
@ -843,6 +858,53 @@ class Drupal6FieldInstance extends Drupal6DumpBase {
|
||||||
))
|
))
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
|
$this->createTable('content_field_test', array(
|
||||||
|
'description' => 'Table for field_test',
|
||||||
|
'fields' => array(
|
||||||
|
'vid' => array(
|
||||||
|
'description' => 'The primary identifier for this version.',
|
||||||
|
'type' => 'serial',
|
||||||
|
'unsigned' => TRUE,
|
||||||
|
'not null' => TRUE,
|
||||||
|
),
|
||||||
|
'nid' => array(
|
||||||
|
'description' => 'The {node} this version belongs to.',
|
||||||
|
'type' => 'int',
|
||||||
|
'unsigned' => TRUE,
|
||||||
|
'not null' => TRUE,
|
||||||
|
'default' => 0,
|
||||||
|
),
|
||||||
|
'field_test_value' => array(
|
||||||
|
'description' => 'Test field value.',
|
||||||
|
'type' => 'varchar',
|
||||||
|
'length' => 255,
|
||||||
|
'not null' => TRUE,
|
||||||
|
'default' => '',
|
||||||
|
),
|
||||||
|
'field_test_format' => array(
|
||||||
|
'type' => 'int',
|
||||||
|
'unsigned' => TRUE,
|
||||||
|
'not null' => TRUE,
|
||||||
|
'default' => 0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'primary key' => array('vid'),
|
||||||
|
));
|
||||||
|
$this->database->insert('content_field_test')->fields(array(
|
||||||
|
'vid',
|
||||||
|
'nid',
|
||||||
|
'field_test_value',
|
||||||
|
'field_test_format',
|
||||||
|
))
|
||||||
|
->values(array(
|
||||||
|
'vid' => 1,
|
||||||
|
'nid' => 1,
|
||||||
|
'field_test_value' => 'This is a shared text field',
|
||||||
|
'field_test_format' => 1,
|
||||||
|
))
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
|
||||||
$this->createTable('content_field_test_two', array(
|
$this->createTable('content_field_test_two', array(
|
||||||
'description' => 'Table for field_test_two',
|
'description' => 'Table for field_test_two',
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
|
|
|
@ -303,12 +303,12 @@ class Drupal6Node extends Drupal6DumpBase {
|
||||||
'unsigned' => TRUE,
|
'unsigned' => TRUE,
|
||||||
'not null' => TRUE,
|
'not null' => TRUE,
|
||||||
),
|
),
|
||||||
'field_test_value' => array(
|
'field_test_three_value' => array(
|
||||||
'description' => 'Test field column.',
|
'description' => 'Test field column.',
|
||||||
'type' => 'varchar',
|
'type' => 'numeric',
|
||||||
'length' => 255,
|
'precision' => 10,
|
||||||
'not null' => TRUE,
|
'scale' => 2,
|
||||||
'default' => '',
|
'not null' => FALSE
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'primary key' => array('vid'),
|
'primary key' => array('vid'),
|
||||||
|
@ -318,12 +318,12 @@ class Drupal6Node extends Drupal6DumpBase {
|
||||||
array(
|
array(
|
||||||
'nid',
|
'nid',
|
||||||
'vid',
|
'vid',
|
||||||
'field_test_value',
|
'field_test_three_value',
|
||||||
))
|
))
|
||||||
->values(array(
|
->values(array(
|
||||||
'nid' => 1,
|
'nid' => 1,
|
||||||
'vid' => 1,
|
'vid' => 1,
|
||||||
'field_test_value' => 'This is a text field',
|
'field_test_three_value' => '42.42',
|
||||||
))
|
))
|
||||||
->execute();
|
->execute();
|
||||||
$this->setModuleVersion('content', 6001);
|
$this->setModuleVersion('content', 6001);
|
||||||
|
|
|
@ -58,6 +58,16 @@ class MigrateCckFieldValuesTest extends MigrateNodeTestBase {
|
||||||
'field_name' => 'field_test_two',
|
'field_name' => 'field_test_two',
|
||||||
'bundle' => 'story',
|
'bundle' => 'story',
|
||||||
))->save();
|
))->save();
|
||||||
|
entity_create('field_config', array(
|
||||||
|
'entity_type' => 'node',
|
||||||
|
'name' => 'field_test_three',
|
||||||
|
'type' => 'decimal',
|
||||||
|
))->save();
|
||||||
|
entity_create('field_instance_config', array(
|
||||||
|
'entity_type' => 'node',
|
||||||
|
'field_name' => 'field_test_three',
|
||||||
|
'bundle' => 'story',
|
||||||
|
))->save();
|
||||||
|
|
||||||
// Add some id mappings for the dependant migrations.
|
// Add some id mappings for the dependant migrations.
|
||||||
$id_mappings = array(
|
$id_mappings = array(
|
||||||
|
@ -87,9 +97,11 @@ class MigrateCckFieldValuesTest extends MigrateNodeTestBase {
|
||||||
*/
|
*/
|
||||||
public function testCckFields() {
|
public function testCckFields() {
|
||||||
$node = node_load(1);
|
$node = node_load(1);
|
||||||
$this->assertEqual($node->field_test->value, 'This is a text field', "Single field storage field is correct.");
|
$this->assertEqual($node->field_test->value, 'This is a shared text field', "Shared field storage field is correct.");
|
||||||
|
$this->assertEqual($node->field_test->format, 1, "Shared field storage field with multiple columns is correct.");
|
||||||
$this->assertEqual($node->field_test_two->value, 10, 'Multi field storage field is correct');
|
$this->assertEqual($node->field_test_two->value, 10, 'Multi field storage field is correct');
|
||||||
$this->assertEqual($node->field_test_two[1]->value, 20, 'Multi field second value is correct.');
|
$this->assertEqual($node->field_test_two[1]->value, 20, 'Multi field second value is correct.');
|
||||||
|
$this->assertEqual($node->field_test_three->value, '42.42', 'Single field second value is correct.');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ class MigrateFieldFormatterSettingsTest extends MigrateDrupalTestBase {
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
entity_create('node_type', array('type' => 'article'))->save();
|
entity_create('node_type', array('type' => 'test_page'))->save();
|
||||||
entity_create('node_type', array('type' => 'story'))->save();
|
entity_create('node_type', array('type' => 'story'))->save();
|
||||||
// Create the node preview view mode.
|
// Create the node preview view mode.
|
||||||
entity_create('view_mode', array('id' => 'node.preview', 'targetEntityType' => 'node'))->save();
|
entity_create('view_mode', array('id' => 'node.preview', 'targetEntityType' => 'node'))->save();
|
||||||
|
@ -102,7 +102,7 @@ class MigrateFieldFormatterSettingsTest extends MigrateDrupalTestBase {
|
||||||
$this->assertEqual($display->getComponent($field_name), $expected);
|
$this->assertEqual($display->getComponent($field_name), $expected);
|
||||||
|
|
||||||
// Test migrate worked with multiple bundles.
|
// Test migrate worked with multiple bundles.
|
||||||
$display = entity_load('entity_view_display', 'node.article.teaser');
|
$display = entity_load('entity_view_display', 'node.test_page.teaser');
|
||||||
$this->assertEqual($display->getComponent($field_name), $expected);
|
$this->assertEqual($display->getComponent($field_name), $expected);
|
||||||
|
|
||||||
// Test RSS because that has been converted from 4 to rss.
|
// Test RSS because that has been converted from 4 to rss.
|
||||||
|
|
|
@ -66,13 +66,13 @@ class MigrateFieldInstanceTest extends MigrateDrupalTestBase {
|
||||||
'd6_node_type' => array(
|
'd6_node_type' => array(
|
||||||
array(array('page'), array('page')),
|
array(array('page'), array('page')),
|
||||||
array(array('story'), array('story')),
|
array(array('story'), array('story')),
|
||||||
array(array('article'), array('article')),
|
array(array('test_page'), array('test_page')),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
$this->prepareIdMappings($id_mappings);
|
$this->prepareIdMappings($id_mappings);
|
||||||
entity_create('node_type', array('type' => 'page'))->save();
|
entity_create('node_type', array('type' => 'page'))->save();
|
||||||
entity_create('node_type', array('type' => 'story'))->save();
|
entity_create('node_type', array('type' => 'story'))->save();
|
||||||
entity_create('node_type', array('type' => 'article'))->save();
|
entity_create('node_type', array('type' => 'test_page'))->save();
|
||||||
|
|
||||||
$migration = entity_load('migration', 'd6_field_instance');
|
$migration = entity_load('migration', 'd6_field_instance');
|
||||||
$dumps = array(
|
$dumps = array(
|
||||||
|
|
|
@ -47,7 +47,7 @@ class MigrateFieldWidgetSettingsTest extends MigrateDrupalTestBase {
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
entity_create('node_type', array('type' => 'article'))->save();
|
entity_create('node_type', array('type' => 'test_page'))->save();
|
||||||
entity_create('node_type', array('type' => 'story'))->save();
|
entity_create('node_type', array('type' => 'story'))->save();
|
||||||
|
|
||||||
// Add some id mappings for the dependant migrations.
|
// Add some id mappings for the dependant migrations.
|
||||||
|
|
Loading…
Reference in New Issue