diff options
author | Dries Buytaert <dries@buytaert.net> | 2011-05-23 21:00:54 -0400 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2011-05-23 21:00:54 -0400 |
commit | 259d0b8feca71d49c2f79dcce53b3147f7429b75 (patch) | |
tree | 2a1c29bbd6ecefb410f9b34a3ffbba65d1f09f8f | |
parent | 1f17b2c1e2cc602faa99f40f8c0c305df7e17cde (diff) | |
parent | 6c57cfa11d58e8c3b6dd5ccc663ce15e2b8842cd (diff) | |
download | brdo-259d0b8feca71d49c2f79dcce53b3147f7429b75.tar.gz brdo-259d0b8feca71d49c2f79dcce53b3147f7429b75.tar.bz2 |
Merge branch '7.x' of git.drupal.org:project/drupal into 7.x
-rw-r--r-- | modules/block/block.install | 7 | ||||
-rw-r--r-- | modules/comment/comment.install | 20 | ||||
-rw-r--r-- | modules/field/field.attach.inc | 2 | ||||
-rw-r--r-- | modules/field/tests/field.test | 50 | ||||
-rw-r--r-- | modules/field/tests/field_test.module | 4 | ||||
-rw-r--r-- | modules/node/node.install | 23 | ||||
-rw-r--r-- | modules/poll/poll.install | 8 | ||||
-rw-r--r-- | modules/system/system.install | 13 | ||||
-rw-r--r-- | modules/user/user.install | 13 |
9 files changed, 128 insertions, 12 deletions
diff --git a/modules/block/block.install b/modules/block/block.install index fcb95fc4f..c45b076bf 100644 --- a/modules/block/block.install +++ b/modules/block/block.install @@ -461,5 +461,12 @@ function block_update_7007() { } /** + * Update database to match Drupal 7 schema. + */ +function block_update_7008() { + db_drop_field('block', 'throttle'); +} + +/** * @} End of "addtogroup updates-6.x-to-7.x" */ diff --git a/modules/comment/comment.install b/modules/comment/comment.install index 51bfa7453..d64b3acde 100644 --- a/modules/comment/comment.install +++ b/modules/comment/comment.install @@ -344,6 +344,26 @@ function comment_update_7007() { } /** + * Update database to match Drupal 7 schema. + */ +function comment_update_7008() { + // Update default status to 1. + db_change_field('comment', 'status', 'status', array( + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 1, + 'size' => 'tiny', + )); + + // Realign indexes. + db_drop_index('comment', 'comment_status_pid'); + db_add_index('comment', 'comment_status_pid', array('pid', 'status')); + db_drop_index('comment', 'comment_pid_status'); + db_drop_index('comment', 'nid'); +} + +/** * @} End of "addtogroup updates-6.x-to-7.x" */ diff --git a/modules/field/field.attach.inc b/modules/field/field.attach.inc index 3b15c76c8..4ca15f543 100644 --- a/modules/field/field.attach.inc +++ b/modules/field/field.attach.inc @@ -348,7 +348,7 @@ function _field_invoke_multiple($op, $entity_type, $entities, &$a = NULL, &$b = // fields with an empty array (those are not equivalent on update). foreach ($grouped_entities[$field_id] as $id => $entity) { foreach ($grouped_items[$field_id] as $langcode => $items) { - if ($grouped_items[$field_id][$langcode][$id] !== array() || isset($entity->{$field_name}[$langcode])) { + if (isset($grouped_items[$field_id][$langcode][$id]) && ($grouped_items[$field_id][$langcode][$id] !== array() || isset($entity->{$field_name}[$langcode]))) { $entity->{$field_name}[$langcode] = $grouped_items[$field_id][$langcode][$id]; } } diff --git a/modules/field/tests/field.test b/modules/field/tests/field.test index 97510e476..9281273f6 100644 --- a/modules/field/tests/field.test +++ b/modules/field/tests/field.test @@ -2690,7 +2690,7 @@ class FieldTranslationsTestCase extends FieldTestCase { $extra_languages = mt_rand(1, 4); $languages = $available_languages = field_available_languages($this->entity_type, $this->field); for ($i = 0; $i < $extra_languages; ++$i) { - $languages[] = $this->randomString(2); + $languages[] = $this->randomName(2); } // For each given language provide some random values. @@ -2715,10 +2715,14 @@ class FieldTranslationsTestCase extends FieldTestCase { * Test the multilanguage logic of _field_invoke_multiple(). */ function testFieldInvokeMultiple() { + // Enable field translations for the entity. + field_test_entity_info_translatable('test_entity', TRUE); + $values = array(); + $options = array(); $entities = array(); $entity_type = 'test_entity'; - $entity_count = mt_rand(1, 5); + $entity_count = mt_rand(2, 5); $available_languages = field_available_languages($this->entity_type, $this->field); for ($id = 1; $id <= $entity_count; ++$id) { @@ -2729,29 +2733,55 @@ class FieldTranslationsTestCase extends FieldTestCase { // correctly uses the result of field_available_languages(). $extra_languages = mt_rand(1, 4); for ($i = 0; $i < $extra_languages; ++$i) { - $languages[] = $this->randomString(2); + $languages[] = $this->randomName(2); } // For each given language provide some random values. - foreach ($languages as $langcode) { - for ($delta = 0; $delta < $this->field['cardinality']; $delta++) { - $values[$id][$langcode][$delta]['value'] = mt_rand(1, 127); + $language_count = count($languages); + for ($i = 0; $i < $language_count; ++$i) { + $langcode = $languages[$i]; + // Avoid to populate at least one field translation to check that + // per-entity language suggestions work even when available field values + // are different for each language. + if ($i !== $id) { + for ($delta = 0; $delta < $this->field['cardinality']; $delta++) { + $values[$id][$langcode][$delta]['value'] = mt_rand(1, 127); + } + } + // Ensure that a language for which there is no field translation is + // used as display language to prepare per-entity language suggestions. + elseif (!isset($display_language)) { + $display_language = $langcode; } } + $entity->{$this->field_name} = $values[$id]; $entities[$id] = $entity; + + // Store per-entity language suggestions. + $options['language'][$id] = field_language($entity_type, $entity, NULL, $display_language); } $grouped_results = _field_invoke_multiple('test_op_multiple', $entity_type, $entities); foreach ($grouped_results as $id => $results) { foreach ($results as $langcode => $result) { - $hash = hash('sha256', serialize(array($entity_type, $entities[$id], $this->field_name, $langcode, $values[$id][$langcode]))); - // Check whether the parameters passed to _field_invoke() were correctly - // forwarded to the callback function. - $this->assertEqual($hash, $result, t('The result for entity %id/%language is correctly stored.', array('%id' => $id, '%language' => $langcode))); + if (isset($values[$id][$langcode])) { + $hash = hash('sha256', serialize(array($entity_type, $entities[$id], $this->field_name, $langcode, $values[$id][$langcode]))); + // Check whether the parameters passed to _field_invoke() were correctly + // forwarded to the callback function. + $this->assertEqual($hash, $result, t('The result for entity %id/%language is correctly stored.', array('%id' => $id, '%language' => $langcode))); + } } $this->assertEqual(count($results), count($available_languages), t('No unavailable language has been processed for entity %id.', array('%id' => $id))); } + + $null = NULL; + $grouped_results = _field_invoke_multiple('test_op_multiple', $entity_type, $entities, $null, $null, $options); + foreach ($grouped_results as $id => $results) { + foreach ($results as $langcode => $result) { + $this->assertTrue(isset($options['language'][$id]), t('The result language %language for entity %id was correctly suggested (display language: %display_language).', array('%id' => $id, '%language' => $langcode, '%display_language' => $display_language))); + } + } } /** diff --git a/modules/field/tests/field_test.module b/modules/field/tests/field_test.module index 09415e216..9e2fef62c 100644 --- a/modules/field/tests/field_test.module +++ b/modules/field/tests/field_test.module @@ -88,7 +88,9 @@ function field_test_field_test_op($entity_type, $entity, $field, $instance, $lan function field_test_field_test_op_multiple($entity_type, $entities, $field, $instances, $langcode, &$items) { $result = array(); foreach ($entities as $id => $entity) { - $result[$id] = array($langcode => hash('sha256', serialize(array($entity_type, $entity, $field['field_name'], $langcode, $items[$id])))); + if (isset($items[$id])) { + $result[$id] = array($langcode => hash('sha256', serialize(array($entity_type, $entity, $field['field_name'], $langcode, $items[$id])))); + } } return $result; } diff --git a/modules/node/node.install b/modules/node/node.install index 14290e3ad..852c1117b 100644 --- a/modules/node/node.install +++ b/modules/node/node.install @@ -837,5 +837,28 @@ function node_update_7010() { } /** + * Update the database from Drupal 6 to match the schema. + */ +function node_update_7011() { + // Drop node moderation field. + db_drop_field('node', 'moderate'); + db_drop_index('node', 'node_moderate'); + + // Change {node_revision}.status field to default to 1. + db_change_field('node_revision', 'status', 'status', array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 1, + )); + + // Change {node_type}.module field default. + db_change_field('node_type', 'module', 'module', array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + )); +} + +/** * @} End of "addtogroup updates-6.x-to-7.x" */ diff --git a/modules/poll/poll.install b/modules/poll/poll.install index d74ff986a..8c73cf43a 100644 --- a/modules/poll/poll.install +++ b/modules/poll/poll.install @@ -196,3 +196,11 @@ function poll_update_7003() { 'description' => 'The sort order of this choice among all choices for the same node.', )); } + +/** + * Update the database to match the schema. + */ +function poll_update_7004() { + // Remove field default. + db_change_field('poll_vote', 'chid', 'chid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE)); +} diff --git a/modules/system/system.install b/modules/system/system.install index b662040d6..e06744460 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -2953,6 +2953,19 @@ function system_update_7070() { } /** + * Add index missed during upgrade, and fix field default. + */ +function system_update_7071() { + db_drop_index('date_format_type', 'title'); + db_add_index('date_format_type', 'title', array('title')); + db_change_field('registry', 'filename', 'filename', array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + )); +} + +/** * @} End of "defgroup updates-6.x-to-7.x" * The next series of updates should start at 8000. */ diff --git a/modules/user/user.install b/modules/user/user.install index 09678187e..df94ad537 100644 --- a/modules/user/user.install +++ b/modules/user/user.install @@ -854,5 +854,18 @@ function user_update_7015() { } /** + * Update the database to match the schema. + */ +function user_update_7016() { + // Add field default. + db_change_field('users', 'uid', 'uid', array( + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + )); +} + +/** * @} End of "addtogroup updates-6.x-to-7.x" */ |