Commit 4e06a759 authored by alexpott's avatar alexpott

Issue #2348447 by quietone, benjy, grahl, Cristian.Andrei: Undefined index exclude

parent 7aad4bc4
...@@ -31,7 +31,7 @@ protected function runQuery() { ...@@ -31,7 +31,7 @@ protected function runQuery() {
$field_name = $field_row['field_name']; $field_name = $field_row['field_name'];
foreach ($this->getViewModes() as $view_mode) { foreach ($this->getViewModes() as $view_mode) {
if (isset($field_row['display_settings'][$view_mode]) && !$field_row['display_settings'][$view_mode]['exclude']) { if (isset($field_row['display_settings'][$view_mode]) && empty($field_row['display_settings'][$view_mode]['exclude'])) {
$index = $view_mode . "." . $bundle . "." . $field_name; $index = $view_mode . "." . $bundle . "." . $field_name;
$rows[$index]['entity_type'] = 'node'; $rows[$index]['entity_type'] = 'node';
$rows[$index]['view_mode'] = $view_mode; $rows[$index]['view_mode'] = $view_mode;
......
...@@ -26,7 +26,7 @@ protected function runQuery() { ...@@ -26,7 +26,7 @@ protected function runQuery() {
while ($field_row = $result->fetchAssoc()) { while ($field_row = $result->fetchAssoc()) {
$field_row['display_settings'] = unserialize($field_row['display_settings']); $field_row['display_settings'] = unserialize($field_row['display_settings']);
foreach ($this->getViewModes() as $view_mode) { foreach ($this->getViewModes() as $view_mode) {
if (isset($field_row['display_settings'][$view_mode]) && !$field_row['display_settings'][$view_mode]['exclude']) { if (isset($field_row['display_settings'][$view_mode]) && empty($field_row['display_settings'][$view_mode]['exclude'])) {
if (!isset($rows[$view_mode])) { if (!isset($rows[$view_mode])) {
$rows[$view_mode]['entity_type'] = 'node'; $rows[$view_mode]['entity_type'] = 'node';
$rows[$view_mode]['view_mode'] = $view_mode; $rows[$view_mode]['view_mode'] = $view_mode;
......
...@@ -854,6 +854,48 @@ public function load() { ...@@ -854,6 +854,48 @@ public function load() {
)), )),
'description' => 'An example integer field.', 'description' => 'An example integer field.',
)) ))
->values(array(
'field_name' => 'field_test_exclude_unset',
'type_name' => 'story',
'weight' => 1,
'label' => 'Text Field',
'widget_type' => 'text_textfield',
'widget_settings' => serialize(array(
'rows' => 5,
'size' => '60',
'default_value' => array(
0 => array(
'value' => 'text for default value',
'_error_element' => 'default_value_widget][field_test][0][value',
),
),
'default_value_php' => NULL,
)),
'display_settings' => serialize(array(
'weight' => 1,
'parent' => '',
'label' => array(
'format' => 'above',
),
1 => array(
'format' => 'default',
),
'teaser' => array(
'format' => 'trimmed',
),
'full' => array(
'format' => 'default',
),
4 => array(
'format' => 'trimmed',
),
5 => array(
'format' => 'default',
'exclude' => 1,
),
)),
'description' => 'An example text field without exclude.',
))
->execute(); ->execute();
// Create the field table. // Create the field table.
...@@ -1178,6 +1220,30 @@ public function load() { ...@@ -1178,6 +1220,30 @@ public function load() {
)), )),
'active' => 1, 'active' => 1,
)) ))
->values(array(
'field_name' => 'field_test_exclude_unset',
'module' => '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:"";}',
'multiple' => 0,
'db_storage' => 0,
'db_columns' => serialize(array(
'value' => array(
'type' => 'text',
'size' => 'big',
'not null' => FALSE,
'sortable' => TRUE,
'views' => TRUE,
),
'format' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
)),
'active' => 1,
))
->execute(); ->execute();
$this->createTable('content_field_test', array( $this->createTable('content_field_test', array(
...@@ -1337,6 +1403,52 @@ public function load() { ...@@ -1337,6 +1403,52 @@ public function load() {
'delta' => 1, 'delta' => 1,
)) ))
->execute(); ->execute();
$this->createTable('content_field_test_exclude_unset', array(
'description' => 'Table for field_exlcude',
'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_exclude_unset_value' => array(
'description' => 'Test field value.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'field_test_exclude_unset_format' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array('vid'),
));
$this->database->insert('content_field_test_exclude_unset')->fields(array(
'vid',
'nid',
'field_test_exclude_unset_value',
'field_test_exclude_unset_format',
))
->values(array(
'vid' => 1,
'nid' => 1,
'field_test_exclude_unset_value' => 'This is a field with exclude unset.',
'field_test_exclude_unset_format' => 1,
))
->execute();
$this->setModuleVersion('content', '6001'); $this->setModuleVersion('content', '6001');
} }
......
...@@ -70,6 +70,16 @@ protected function setUp() { ...@@ -70,6 +70,16 @@ protected function setUp() {
'field_name' => 'field_test_integer_selectlist', 'field_name' => 'field_test_integer_selectlist',
'bundle' => 'story', 'bundle' => 'story',
))->save(); ))->save();
entity_create('field_storage_config', array(
'entity_type' => 'node',
'field_name' => 'field_test_exclude_unset',
'type' => 'text',
))->save();
entity_create('field_config', array(
'entity_type' => 'node',
'field_name' => 'field_test_exclude_unset',
'bundle' => 'story',
))->save();
entity_create('field_storage_config', array( entity_create('field_storage_config', array(
'entity_type' => 'node', 'entity_type' => 'node',
...@@ -153,6 +163,7 @@ public function testCckFields() { ...@@ -153,6 +163,7 @@ public function testCckFields() {
$this->assertEqual($node->field_test_integer_selectlist[0]->value, '3412', 'Integer select list value is correct'); $this->assertEqual($node->field_test_integer_selectlist[0]->value, '3412', 'Integer select list value is correct');
$this->assertEqual($node->field_test_identical1->value, '1', 'Integer value is correct'); $this->assertEqual($node->field_test_identical1->value, '1', 'Integer value is correct');
$this->assertEqual($node->field_test_identical2->value, '1', 'Integer value is correct'); $this->assertEqual($node->field_test_identical2->value, '1', 'Integer value is correct');
$this->assertEqual($node->field_test_exclude_unset->value, 'This is a field with exclude unset.', 'Field with exclude unset is correct.');
// Test that link fields are migrated. // Test that link fields are migrated.
$this->assertIdentical($node->field_test_link->url, 'http://drupal.org/project/drupal'); $this->assertIdentical($node->field_test_link->url, 'http://drupal.org/project/drupal');
......
...@@ -59,6 +59,7 @@ protected function setUp() { ...@@ -59,6 +59,7 @@ protected function setUp() {
array(array('field_test_date'), array('node', 'field_test_date')), array(array('field_test_date'), array('node', 'field_test_date')),
array(array('field_test_datestamp'), array('node', 'field_test_datestamp')), array(array('field_test_datestamp'), array('node', 'field_test_datestamp')),
array(array('field_test_datetime'), array('node', 'field_test_datetime')), array(array('field_test_datetime'), array('node', 'field_test_datetime')),
array(array('field_test_exclude_unset'), array('node', 'field_test_exclude_unset')),
), ),
); );
$this->prepareMigrations($id_mappings); $this->prepareMigrations($id_mappings);
...@@ -112,6 +113,9 @@ public function testEntityDisplaySettings() { ...@@ -112,6 +113,9 @@ public function testEntityDisplaySettings() {
$this->assertTrue(isset($content['field_test']), 'Settings for field_test exist.'); $this->assertTrue(isset($content['field_test']), 'Settings for field_test exist.');
$this->assertTrue(isset($content['field_test_two']), "Settings for field_test_two exist."); $this->assertTrue(isset($content['field_test_two']), "Settings for field_test_two exist.");
// Check that we can migrate a field where exclude is not set.
$this->assertTrue(isset($content['field_test_exclude_unset']), "Settings for field_test_exclude_unset exist.");
// Test the number field formatter settings are correct. // Test the number field formatter settings are correct.
$expected['weight'] = 2; $expected['weight'] = 2;
$expected['type'] = 'number_integer'; $expected['type'] = 'number_integer';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment