diff options
Diffstat (limited to 'modules/field')
43 files changed, 307 insertions, 227 deletions
diff --git a/modules/field/field.api.php b/modules/field/field.api.php index bc31b8ac3..9c52d24ef 100644 --- a/modules/field/field.api.php +++ b/modules/field/field.api.php @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @ingroup field_fieldable_type @@ -16,7 +15,7 @@ * * Fieldable entities or modules that want to have their components supported * should expose them using this hook. The user-defined settings (weight, - * visibility) are automatically applied on rendered forms and displayed + * visible) are automatically applied on rendered forms and displayed * entities in a #pre_render callback added by field_attach_form() and * field_attach_view(). * @@ -758,7 +757,7 @@ function hook_field_widget_info_alter(&$info) { /** * Return the form for a single field widget. * - * Field widget form elements should be based on the passed in $element, which + * Field widget form elements should be based on the passed-in $element, which * contains the base form element properties derived from the field * configuration. * @@ -1271,7 +1270,7 @@ function hook_field_attach_delete_revision($entity_type, $entity) { */ function hook_field_attach_purge($entity_type, $entity, $field, $instance) { // find the corresponding data in mymodule and purge it - if($entity_type == 'node' && $field->field_name == 'my_field_name') { + if ($entity_type == 'node' && $field->field_name == 'my_field_name') { mymodule_remove_mydata($entity->nid); } } @@ -1319,7 +1318,7 @@ function hook_field_attach_view_alter(&$output, $context) { * * This hook is invoked after the field module has performed the operation. * - * @param &$entity + * @param $entity * The entity being prepared for translation. * @param $context * An associative array containing: @@ -1362,7 +1361,7 @@ function hook_field_language_alter(&$display_language, $context) { * This hook is invoked from field_available_languages() to allow modules to * alter the array of available languages for the given field. * - * @param &$languages + * @param $languages * A reference to an array of language codes to be made available. * @param $context * An associative array containing: @@ -2205,7 +2204,7 @@ function hook_field_display_ENTITY_TYPE_alter(&$display, $context) { */ function hook_field_extra_fields_display_alter(&$displays, $context) { if ($context['entity_type'] == 'taxonomy_term' && $context['view_mode'] == 'full') { - $displays['description']['visibility'] = FALSE; + $displays['description']['visible'] = FALSE; } } @@ -2416,7 +2415,7 @@ function hook_field_delete_instance($instance) { * @param $field * The field record just read from the database. */ -function hook_field_read_field(&$field) { +function hook_field_read_field($field) { // @todo Needs function body. } diff --git a/modules/field/field.attach.inc b/modules/field/field.attach.inc index 59c91f959..4ca15f543 100644 --- a/modules/field/field.attach.inc +++ b/modules/field/field.attach.inc @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file @@ -258,9 +257,9 @@ function _field_invoke($op, $entity_type, $entity, &$a = NULL, &$b = NULL, $opti * - 'deleted': If TRUE, the function will operate on deleted fields * as well as non-deleted fields. If unset or FALSE, only * non-deleted fields are operated on. - * - 'language': A language code or an array of language codes keyed by field - * name. It will be used to narrow down to a single value the available - * languages to act on. + * - 'language': A language code or an array of arrays of language codes keyed + * by entity id and field name. It will be used to narrow down to a single + * value the available languages to act on. * * @return * An array of returned values keyed by entity id. @@ -312,7 +311,8 @@ function _field_invoke_multiple($op, $entity_type, $entities, &$a = NULL, &$b = // Unless a language suggestion is provided we iterate on all the // available languages. $available_languages = field_available_languages($entity_type, $field); - $languages = _field_language_suggestion($available_languages, $options['language'], $field_name); + $language = !empty($options['language'][$id]) ? $options['language'][$id] : $options['language']; + $languages = _field_language_suggestion($available_languages, $language, $field_name); foreach ($languages as $langcode) { $grouped_items[$field_id][$langcode][$id] = isset($entity->{$field_name}[$langcode]) ? $entity->{$field_name}[$langcode] : array(); } @@ -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]; } } @@ -780,11 +780,11 @@ function field_attach_validate($entity_type, $entity) { * There are two levels of validation for fields in forms: widget * validation, and field validation. * - Widget validation steps are specific to a given widget's own form - * structure and UI metaphors. They are executed through FAPI's - * #element_validate property during normal form validation. + * structure and UI metaphors. They are executed through FAPI's + * #element_validate property during normal form validation. * - Field validation steps are common to a given field type, independently of - * the specific widget being used in a given form. They are defined in the - * field type's implementation of hook_field_validate(). + * the specific widget being used in a given form. They are defined in the + * field type's implementation of hook_field_validate(). * * This function performs field validation in the context of a form * submission. It converts field validation errors into form errors @@ -878,7 +878,7 @@ function field_attach_presave($entity_type, $entity) { /** * Save field data for a new entity. * - * The passed in entity must already contain its id and (if applicable) + * The passed-in entity must already contain its id and (if applicable) * revision id attributes. * Default values (if any) will be saved for fields not present in the * $entity. @@ -1075,8 +1075,13 @@ function field_attach_delete_revision($entity_type, $entity) { * An array of entities, keyed by entity id. * @param $view_mode * View mode, e.g. 'full', 'teaser'... + * @param $langcode + * (Optional) The language the field values are to be shown in. If no language + * is provided the current language is used. */ -function field_attach_prepare_view($entity_type, $entities, $view_mode) { +function field_attach_prepare_view($entity_type, $entities, $view_mode, $langcode = NULL) { + $options = array('language' => array()); + // To ensure hooks are only run once per entity, only process items without // the _field_view_prepared flag. // @todo: resolve this more generally for both entity and field level hooks. @@ -1086,17 +1091,22 @@ function field_attach_prepare_view($entity_type, $entities, $view_mode) { // Add this entity to the items to be prepared. $prepare[$id] = $entity; + // Determine the actual language to display for each field, given the + // languages available in the field data. + $options['language'][$id] = field_language($entity_type, $entity, NULL, $langcode); + // Mark this item as prepared. $entity->_field_view_prepared = TRUE; } } + $null = NULL; // First let the field types do their preparation. - _field_invoke_multiple('prepare_view', $entity_type, $prepare); + _field_invoke_multiple('prepare_view', $entity_type, $prepare, $null, $null, $options); // Then let the formatters do their own specific massaging. // field_default_prepare_view() takes care of dispatching to the correct // formatters according to the display settings for the view mode. - _field_invoke_multiple_default('prepare_view', $entity_type, $prepare, $view_mode); + _field_invoke_multiple_default('prepare_view', $entity_type, $prepare, $view_mode, $null, $options); } /** diff --git a/modules/field/field.crud.inc b/modules/field/field.crud.inc index eda3218c5..339e9c4e3 100644 --- a/modules/field/field.crud.inc +++ b/modules/field/field.crud.inc @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file @@ -422,7 +421,6 @@ function field_delete_field($field_name) { * will be given the following default values: * - label: the field name * - description: empty string - * - weight: 0 * - required: FALSE * - default_value_function: empty string * - settings: each omitted setting is given the default value specified in @@ -635,12 +633,11 @@ function _field_write_instance($instance, $update = FALSE) { } /** - * Reads a single instance record directly from the database. + * Reads a single instance record from the database. * - * Generally, you should use the field_info_instance() instead. - * - * This function will not return deleted instances. Use - * field_read_instances() instead for this purpose. + * Generally, you should use field_info_instance() instead, as it + * provides caching and allows other modules the opportunity to + * append additional formatters, widgets, and other information. * * @param $entity_type * The type of entity to which the field is bound. diff --git a/modules/field/field.default.inc b/modules/field/field.default.inc index f078d24ca..a10d1387f 100644 --- a/modules/field/field.default.inc +++ b/modules/field/field.default.inc @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file @@ -82,7 +81,7 @@ function field_default_validate($entity_type, $entity, $field, $instance, $langc if ($field['cardinality'] != FIELD_CARDINALITY_UNLIMITED && count($items) > $field['cardinality']) { $errors[$field['field_name']][$langcode][0][] = array( 'error' => 'field_cardinality', - 'message' => t('%name: this field cannot hold more than @count values.', array('%name' => t($instance['label']), '@count' => $field['cardinality'])), + 'message' => t('%name: this field cannot hold more than @count values.', array('%name' => $instance['label'], '@count' => $field['cardinality'])), ); } } @@ -135,21 +134,25 @@ function field_default_insert($entity_type, $entity, $field, $instance, $langcod * - the name of a view mode * - or an array of display settings to use for display, as found in the * 'display' entry of $instance definitions. -*/ + */ function field_default_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $display) { // Group entities, instances and items by formatter module. $modules = array(); foreach ($instances as $id => $instance) { if (is_string($display)) { $view_mode = $display; - $display = field_get_display($instance, $view_mode, $entities[$id]); + $instance_display = field_get_display($instance, $view_mode, $entities[$id]); + } + else { + $instance_display = $display; } - if ($display['type'] !== 'hidden') { - $module = $display['module']; + + if ($instance_display['type'] !== 'hidden') { + $module = $instance_display['module']; $modules[$module] = $module; $grouped_entities[$module][$id] = $entities[$id]; $grouped_instances[$module][$id] = $instance; - $grouped_displays[$module][$id] = $display; + $grouped_displays[$module][$id] = $instance_display; // hook_field_formatter_prepare_view() alters $items by reference. $grouped_items[$module][$id] = &$items[$id]; } @@ -211,7 +214,7 @@ function field_default_view($entity_type, $entity, $field, $instance, $langcode, $info = array( '#theme' => 'field', '#weight' => $display['weight'], - '#title' => t($instance['label']), + '#title' => $instance['label'], '#access' => field_access('view', $field, $entity_type, $entity), '#label_display' => $display['label'], '#view_mode' => $view_mode, diff --git a/modules/field/field.form.inc b/modules/field/field.form.inc index 4acd1fdfa..845f04109 100644 --- a/modules/field/field.form.inc +++ b/modules/field/field.form.inc @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file @@ -70,7 +69,7 @@ function field_default_form($entity_type, $entity, $field, $instance, $langcode, '#language' => $langcode, '#field_parents' => $parents, '#columns' => array_keys($field['columns']), - '#title' => check_plain(t($instance['label'])), + '#title' => check_plain($instance['label']), '#description' => field_filter_xss($instance['description']), // Only the first widget should be required. '#required' => $delta == 0 && $instance['required'], @@ -152,8 +151,8 @@ function field_multiple_value_form($field, $instance, $langcode, $items, &$form, break; } - $title = check_plain(t($instance['label'])); - $description = field_filter_xss(t($instance['description'])); + $title = check_plain($instance['label']); + $description = field_filter_xss($instance['description']); $id_prefix = implode('-', array_merge($parents, array($field_name))); $wrapper_id = drupal_html_id($id_prefix . '-add-more-wrapper'); @@ -414,7 +413,7 @@ function field_add_more_js($form, $form_state) { return; } - // Add a DIV around the delta receiving the AJAX effect. + // Add a DIV around the delta receiving the Ajax effect. $delta = $element['#max_delta']; $element[$delta]['#prefix'] = '<div class="ajax-new-content">' . (isset($element[$delta]['#prefix']) ? $element[$delta]['#prefix'] : ''); $element[$delta]['#suffix'] = (isset($element[$delta]['#suffix']) ? $element[$delta]['#suffix'] : '') . '</div>'; diff --git a/modules/field/field.info b/modules/field/field.info index 3a1b20d51..f8a331a00 100644 --- a/modules/field/field.info +++ b/modules/field/field.info @@ -1,4 +1,3 @@ -; $Id$ name = Field description = Field API to add fields to entities like nodes and users. package = Core diff --git a/modules/field/field.info.inc b/modules/field/field.info.inc index 4a0248ffd..02707f6d3 100644 --- a/modules/field/field.info.inc +++ b/modules/field/field.info.inc @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file @@ -287,8 +286,6 @@ function _field_info_prepare_field($field) { * Field instance array. */ function _field_info_prepare_instance($instance, $field) { - $field_type = field_info_field_types($field['type']); - // Make sure all expected instance settings are present. $instance['settings'] += field_info_instance_settings($field['type']); @@ -735,7 +732,7 @@ function field_info_instance($entity_type, $field_name, $bundle_name) { * 'default' => array( * 'weight' => The weight of the component in displayed entities in * this view mode, - * 'visibility' => Whether the component is visible or hidden in + * 'visible' => TRUE if the component is visible, FALSE if hidden, in * displayed entities in this view mode, * ), * 'teaser' => array( @@ -793,7 +790,7 @@ function field_info_max_weight($entity_type, $bundle, $context) { if ($context == 'form') { $weights[] = $instance['widget']['weight']; } - else { + elseif (isset($instance['display'][$context]['weight'])) { $weights[] = $instance['display'][$context]['weight']; } } diff --git a/modules/field/field.install b/modules/field/field.install index 02455c4e1..d56eb904c 100644 --- a/modules/field/field.install +++ b/modules/field/field.install @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file @@ -310,18 +309,27 @@ function _update_7000_field_delete_instance($field_name, $entity_type, $bundle) /** * Utility function: fetch all the field definitions from the database. * + * 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. */ -function _update_7000_field_read_fields(array $conditions = array()) { +function _update_7000_field_read_fields(array $conditions = array(), $key = 'id') { $fields = array(); $query = db_select('field_config', 'fc', array('fetch' => PDO::FETCH_ASSOC)) - ->fields('fc') - ->condition('deleted', 0); - if (!empty($conditions)) { - foreach ($conditions as $column => $value) { - $query->condition($column, $value); - } + ->fields('fc'); + foreach ($conditions as $column => $value) { + $query->condition($column, $value); } foreach ($query->execute() as $record) { $field = unserialize($record['data']); @@ -338,7 +346,7 @@ function _update_7000_field_read_fields(array $conditions = array()) { $field['translatable'] = $record['translatable']; $field['deleted'] = $record['deleted']; - $fields[$field['field_name']] = $field; + $fields[$field[$key]] = $field; } return $fields; } diff --git a/modules/field/field.module b/modules/field/field.module index 08ee9d594..9e03c8d91 100644 --- a/modules/field/field.module +++ b/modules/field/field.module @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file * Attach custom data fields to Drupal entities. @@ -559,7 +558,7 @@ function _field_sort_items_value_helper($a, $b) { * // the 'default' mode: * 'default' => array( * 'weight' => The weight of the pseudo-field, - * 'visibility' => Whether the pseudo-field is visible or hidden, + * 'visible' => TRUE if the pseudo-field is visible, FALSE if hidden, * ), * 'full' => ... * ), diff --git a/modules/field/field.multilingual.inc b/modules/field/field.multilingual.inc index 10db9546a..00adf9275 100644 --- a/modules/field/field.multilingual.inc +++ b/modules/field/field.multilingual.inc @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file diff --git a/modules/field/modules/field_sql_storage/field_sql_storage.info b/modules/field/modules/field_sql_storage/field_sql_storage.info index 4d7a2e8eb..93138501b 100644 --- a/modules/field/modules/field_sql_storage/field_sql_storage.info +++ b/modules/field/modules/field_sql_storage/field_sql_storage.info @@ -1,4 +1,3 @@ -; $Id$ name = Field SQL storage description = Stores field data in an SQL database. package = Core diff --git a/modules/field/modules/field_sql_storage/field_sql_storage.install b/modules/field/modules/field_sql_storage/field_sql_storage.install index 04d6859f7..647296e4e 100644 --- a/modules/field/modules/field_sql_storage/field_sql_storage.install +++ b/modules/field/modules/field_sql_storage/field_sql_storage.install @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file diff --git a/modules/field/modules/field_sql_storage/field_sql_storage.module b/modules/field/modules/field_sql_storage/field_sql_storage.module index 916649b4e..6f49167ec 100644 --- a/modules/field/modules/field_sql_storage/field_sql_storage.module +++ b/modules/field/modules/field_sql_storage/field_sql_storage.module @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file diff --git a/modules/field/modules/field_sql_storage/field_sql_storage.test b/modules/field/modules/field_sql_storage/field_sql_storage.test index 4a6f96a52..f94344fa2 100644 --- a/modules/field/modules/field_sql_storage/field_sql_storage.test +++ b/modules/field/modules/field_sql_storage/field_sql_storage.test @@ -1,9 +1,8 @@ <?php -// $Id$ /** * @file - * Unit tests for field_sql_ storage.module + * Tests for field_sql_storage.module. * * Field_sql_storage.module implements the default back-end storage plugin * for the Field Strage API. diff --git a/modules/field/modules/list/list.info b/modules/field/modules/list/list.info index 250b1ba28..6bcec5d1e 100644 --- a/modules/field/modules/list/list.info +++ b/modules/field/modules/list/list.info @@ -1,4 +1,3 @@ -; $Id$ name = List description = Defines list field types. Use with Options to create selection lists. package = Core diff --git a/modules/field/modules/list/list.install b/modules/field/modules/list/list.install index cc7bcaf79..91c7649c1 100644 --- a/modules/field/modules/list/list.install +++ b/modules/field/modules/list/list.install @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file @@ -51,7 +50,7 @@ function list_field_schema($field) { */ function list_update_7001() { $fields = _update_7000_field_read_fields(array('module' => 'list')); - foreach ($fields as $field_name => $field) { + foreach ($fields as $field) { $update = array(); // Translate the old string format into the new array format. @@ -61,7 +60,7 @@ function list_update_7001() { $allowed_values = _list_update_7001_extract_allowed_values($allowed_values, $position_keys); // Additionally, float keys need to be disambiguated ('.5' is '0.5'). - if ($field['type'] == 'list_number') { + if ($field['type'] == 'list_number' && !empty($allowed_values)) { $keys = array_map(create_function('$a', 'return (string) (float) $a;'), array_keys($allowed_values)); $allowed_values = array_combine($keys, array_values($allowed_values)); } @@ -116,3 +115,15 @@ function _list_update_7001_extract_allowed_values($string, $position_keys) { return $values; } + +/** + * Re-apply list_update_7001() for deleted fields. + */ +function list_update_7002() { + // See http://drupal.org/node/1022924: list_update_7001() intitally + // overlooked deleted fields, which then caused fatal errors when the fields + // were being purged. + // list_update_7001() has the required checks to ensure it is reentrant, so + // it can simply be executed once more.. + list_update_7001(); +}
\ No newline at end of file diff --git a/modules/field/modules/list/list.module b/modules/field/modules/list/list.module index 160936c1e..608679bbb 100644 --- a/modules/field/modules/list/list.module +++ b/modules/field/modules/list/list.module @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file @@ -380,7 +379,7 @@ function list_field_validate($entity_type, $entity, $field, $instance, $langcode if (!empty($allowed_values) && !isset($allowed_values[$item['value']])) { $errors[$field['field_name']][$langcode][$delta][] = array( 'error' => 'list_illegal_value', - 'message' => t('%name: illegal value.', array('%name' => t($instance['label']))), + 'message' => t('%name: illegal value.', array('%name' => $instance['label'])), ); } } diff --git a/modules/field/modules/list/tests/list.test b/modules/field/modules/list/tests/list.test index 0a5dd50c9..941d2b4cb 100644 --- a/modules/field/modules/list/tests/list.test +++ b/modules/field/modules/list/tests/list.test @@ -1,9 +1,8 @@ <?php -// $Id$ /** * @file - * Tests for the 'List' field types. + * Tests for list.module. */ /** @@ -98,8 +97,8 @@ class ListFieldTestCase extends FieldTestCase { } /** -* List module UI tests. -*/ + * List module UI tests. + */ class ListFieldUITestCase extends FieldTestCase { public static function getInfo() { return array( diff --git a/modules/field/modules/list/tests/list_test.info b/modules/field/modules/list/tests/list_test.info index 62cc3138e..83ae747a9 100644 --- a/modules/field/modules/list/tests/list_test.info +++ b/modules/field/modules/list/tests/list_test.info @@ -1,4 +1,3 @@ -;$Id$ name = "List test" description = "Support module for the List module tests." core = 7.x diff --git a/modules/field/modules/list/tests/list_test.module b/modules/field/modules/list/tests/list_test.module index 4fb1998eb..8d5340412 100644 --- a/modules/field/modules/list/tests/list_test.module +++ b/modules/field/modules/list/tests/list_test.module @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file diff --git a/modules/field/modules/number/number.info b/modules/field/modules/number/number.info index ea1c3651f..203d85d43 100644 --- a/modules/field/modules/number/number.info +++ b/modules/field/modules/number/number.info @@ -1,4 +1,3 @@ -; $Id$ name = Number description = Defines numeric field types. package = Core diff --git a/modules/field/modules/number/number.install b/modules/field/modules/number/number.install index d5e6b1cf2..02c7a3057 100644 --- a/modules/field/modules/number/number.install +++ b/modules/field/modules/number/number.install @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file diff --git a/modules/field/modules/number/number.module b/modules/field/modules/number/number.module index 45ea95455..20e380777 100644 --- a/modules/field/modules/number/number.module +++ b/modules/field/modules/number/number.module @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file @@ -139,13 +138,13 @@ function number_field_validate($entity_type, $entity, $field, $instance, $langco if (is_numeric($instance['settings']['min']) && $item['value'] < $instance['settings']['min']) { $errors[$field['field_name']][$langcode][$delta][] = array( 'error' => 'number_min', - 'message' => t('%name: the value may be no less than %min.', array('%name' => t($instance['label']), '%min' => $instance['settings']['min'])), + 'message' => t('%name: the value may be no less than %min.', array('%name' => $instance['label'], '%min' => $instance['settings']['min'])), ); } if (is_numeric($instance['settings']['max']) && $item['value'] > $instance['settings']['max']) { $errors[$field['field_name']][$langcode][$delta][] = array( 'error' => 'number_max', - 'message' => t('%name: the value may be no greater than %max.', array('%name' => t($instance['label']), '%max' => $instance['settings']['max'])), + 'message' => t('%name: the value may be no greater than %max.', array('%name' => $instance['label'], '%max' => $instance['settings']['max'])), ); } } @@ -368,12 +367,12 @@ function number_field_widget_validate($element, &$form_state) { case 'float': case 'decimal': $regexp = '@[^-0-9\\' . $field['settings']['decimal_separator'] . ']@'; - $message = t('Only numbers and the decimal separator (@separator) allowed in %field.', array('%field' => t($instance['label']), '@separator' => $field['settings']['decimal_separator'])); + $message = t('Only numbers and the decimal separator (@separator) allowed in %field.', array('%field' => $instance['label'], '@separator' => $field['settings']['decimal_separator'])); break; case 'integer': $regexp = '@[^-0-9]@'; - $message = t('Only numbers are allowed in %field.', array('%field' => t($instance['label']))); + $message = t('Only numbers are allowed in %field.', array('%field' => $instance['label'])); break; } if ($value != preg_replace($regexp, '', $value)) { diff --git a/modules/field/modules/number/number.test b/modules/field/modules/number/number.test index a15b6e6aa..ec100f189 100644 --- a/modules/field/modules/number/number.test +++ b/modules/field/modules/number/number.test @@ -1,9 +1,8 @@ <?php -// $Id$ /** * @file - * Tests for number field types. + * Tests for number.module. */ /** diff --git a/modules/field/modules/options/options.api.php b/modules/field/modules/options/options.api.php index 72ee8674b..dfbb631c6 100644 --- a/modules/field/modules/options/options.api.php +++ b/modules/field/modules/options/options.api.php @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file diff --git a/modules/field/modules/options/options.info b/modules/field/modules/options/options.info index f040ae93b..985a74ce7 100644 --- a/modules/field/modules/options/options.info +++ b/modules/field/modules/options/options.info @@ -1,4 +1,3 @@ -; $Id$ name = Options description = Defines selection, check box and radio button widgets for text and numeric fields. package = Core diff --git a/modules/field/modules/options/options.module b/modules/field/modules/options/options.module index abff986fd..385f3f47f 100644 --- a/modules/field/modules/options/options.module +++ b/modules/field/modules/options/options.module @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file diff --git a/modules/field/modules/options/options.test b/modules/field/modules/options/options.test index 31d2617ff..ea58f27ff 100644 --- a/modules/field/modules/options/options.test +++ b/modules/field/modules/options/options.test @@ -1,5 +1,9 @@ <?php -// $Id$ + +/** + * @file + * Tests for options.module. + */ class OptionsWidgetsTestCase extends FieldTestCase { public static function getInfo() { diff --git a/modules/field/modules/text/text.info b/modules/field/modules/text/text.info index 0117dc13c..976e29904 100644 --- a/modules/field/modules/text/text.info +++ b/modules/field/modules/text/text.info @@ -1,4 +1,3 @@ -; $Id$ name = Text description = Defines simple text field types. package = Core diff --git a/modules/field/modules/text/text.install b/modules/field/modules/text/text.install index cd1d9ded5..b9bd25f19 100644 --- a/modules/field/modules/text/text.install +++ b/modules/field/modules/text/text.install @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file @@ -93,7 +92,7 @@ function text_update_7000() { 'module' => 'text', 'storage_type' => 'field_sql_storage', )); - foreach ($fields as $field_name => $field) { + foreach ($fields as $field) { if ($field['deleted']) { $table = "field_deleted_data_{$field['id']}"; $revision_table = "field_deleted_revision_{$field['id']}"; diff --git a/modules/field/modules/text/text.js b/modules/field/modules/text/text.js index f96075ae5..f3ae89430 100644 --- a/modules/field/modules/text/text.js +++ b/modules/field/modules/text/text.js @@ -1,4 +1,3 @@ -// $Id$ (function ($) { diff --git a/modules/field/modules/text/text.module b/modules/field/modules/text/text.module index 08f06229c..89c605cf2 100644 --- a/modules/field/modules/text/text.module +++ b/modules/field/modules/text/text.module @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file diff --git a/modules/field/modules/text/text.test b/modules/field/modules/text/text.test index ee71414cf..b42fed7e0 100644 --- a/modules/field/modules/text/text.test +++ b/modules/field/modules/text/text.test @@ -1,5 +1,9 @@ <?php -// $Id$ + +/** + * @file + * Tests for text.module. + */ class TextFieldTestCase extends DrupalWebTestCase { protected $instance; diff --git a/modules/field/tests/field.test b/modules/field/tests/field.test index 05a6ede01..9281273f6 100644 --- a/modules/field/tests/field.test +++ b/modules/field/tests/field.test @@ -1,9 +1,8 @@ <?php -// $Id$ /** * @file - * Unit test file for fields in core. + * Tests for field.module. */ /** @@ -763,6 +762,55 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { } /** + * Tests the 'multiple entity' behavior of field_attach_prepare_view(). + */ + function testFieldAttachPrepareViewMultiple() { + $entity_type = 'test_entity'; + $langcode = LANGUAGE_NONE; + + // Set the instance to be hidden. + $this->instance['display']['full']['type'] = 'hidden'; + field_update_instance($this->instance); + + // Set up a second instance on another bundle, with a formatter that uses + // hook_field_formatter_prepare_view(). + field_test_create_bundle('test_bundle_2'); + $formatter_setting = $this->randomName(); + $this->instance2 = $this->instance; + $this->instance2['bundle'] = 'test_bundle_2'; + $this->instance2['display']['full'] = array( + 'type' => 'field_test_with_prepare_view', + 'settings' => array( + 'test_formatter_setting_additional' => $formatter_setting, + ) + ); + field_create_instance($this->instance2); + + // Create one entity in each bundle. + $entity1_init = field_test_create_stub_entity(1, 1, 'test_bundle'); + $values1 = $this->_generateTestFieldValues($this->field['cardinality']); + $entity1_init->{$this->field_name}[$langcode] = $values1; + + $entity2_init = field_test_create_stub_entity(2, 2, 'test_bundle_2'); + $values2 = $this->_generateTestFieldValues($this->field['cardinality']); + $entity2_init->{$this->field_name}[$langcode] = $values2; + + // Run prepare_view, and check that the entities come out as expected. + $entity1 = clone($entity1_init); + $entity2 = clone($entity2_init); + field_attach_prepare_view($entity_type, array($entity1->ftid => $entity1, $entity2->ftid => $entity2), 'full'); + $this->assertFalse(isset($entity1->{$this->field_name}[$langcode][0]['additional_formatter_value']), 'Entity 1 did not run through the prepare_view hook.'); + $this->assertTrue(isset($entity2->{$this->field_name}[$langcode][0]['additional_formatter_value']), 'Entity 2 ran through the prepare_view hook.'); + + // Same thing, reversed order. + $entity1 = clone($entity1_init); + $entity2 = clone($entity2_init); + field_attach_prepare_view($entity_type, array($entity2->ftid => $entity2, $entity1->ftid => $entity1), 'full'); + $this->assertFalse(isset($entity1->{$this->field_name}[$langcode][0]['additional_formatter_value']), 'Entity 1 did not run through the prepare_view hook.'); + $this->assertTrue(isset($entity2->{$this->field_name}[$langcode][0]['additional_formatter_value']), 'Entity 2 ran through the prepare_view hook.'); + } + + /** * Test field cache. */ function testFieldAttachCache() { @@ -1448,7 +1496,7 @@ class FieldFormTestCase extends FieldTestCase { $field_values[$weight]['value'] = (string) $value; $pattern[$weight] = "<input [^>]*value=\"$value\" [^>]*"; } - // Press 'add more' button through AJAX, and place the expected HTML result + // Press 'add more' button through Ajax, and place the expected HTML result // as the tested content. $commands = $this->drupalPostAJAX(NULL, $edit, $this->field_name . '_add_more'); $this->content = $commands[1]['data']; @@ -1568,109 +1616,109 @@ class FieldFormTestCase extends FieldTestCase { * Tests Field API form integration within a subform. */ function testNestedFieldForm() { - // Add two instances on the 'test_bundle' - field_create_field($this->field_single); - field_create_field($this->field_unlimited); - $this->instance['field_name'] = 'field_single'; - $this->instance['label'] = 'Single field'; - field_create_instance($this->instance); - $this->instance['field_name'] = 'field_unlimited'; - $this->instance['label'] = 'Unlimited field'; - field_create_instance($this->instance); - - // Create two entities. - $entity_1 = field_test_create_stub_entity(1, 1); - $entity_1->is_new = TRUE; - $entity_1->field_single[LANGUAGE_NONE][] = array('value' => 0); - $entity_1->field_unlimited[LANGUAGE_NONE][] = array('value' => 1); - field_test_entity_save($entity_1); - - $entity_2 = field_test_create_stub_entity(2, 2); - $entity_2->is_new = TRUE; - $entity_2->field_single[LANGUAGE_NONE][] = array('value' => 10); - $entity_2->field_unlimited[LANGUAGE_NONE][] = array('value' => 11); - field_test_entity_save($entity_2); - - // Display the 'combined form'. - $this->drupalGet('test-entity/nested/1/2'); - $this->assertFieldByName('field_single[und][0][value]', 0, t('Entity 1: field_single value appears correctly is the form.')); - $this->assertFieldByName('field_unlimited[und][0][value]', 1, t('Entity 1: field_unlimited value 0 appears correctly is the form.')); - $this->assertFieldByName('entity_2[field_single][und][0][value]', 10, t('Entity 2: field_single value appears correctly is the form.')); - $this->assertFieldByName('entity_2[field_unlimited][und][0][value]', 11, t('Entity 2: field_unlimited value 0 appears correctly is the form.')); - - // Submit the form and check that the entities are updated accordingly. - $edit = array( - 'field_single[und][0][value]' => 1, - 'field_unlimited[und][0][value]' => 2, - 'field_unlimited[und][1][value]' => 3, - 'entity_2[field_single][und][0][value]' => 11, - 'entity_2[field_unlimited][und][0][value]' => 12, - 'entity_2[field_unlimited][und][1][value]' => 13, - ); - $this->drupalPost(NULL, $edit, t('Save')); - field_cache_clear(); - $entity_1 = field_test_create_stub_entity(1); - $entity_2 = field_test_create_stub_entity(2); - $this->assertFieldValues($entity_1, 'field_single', LANGUAGE_NONE, array(1)); - $this->assertFieldValues($entity_1, 'field_unlimited', LANGUAGE_NONE, array(2, 3)); - $this->assertFieldValues($entity_2, 'field_single', LANGUAGE_NONE, array(11)); - $this->assertFieldValues($entity_2, 'field_unlimited', LANGUAGE_NONE, array(12, 13)); - - // Submit invalid values and check that errors are reported on the - // correct widgets. - $edit = array( - 'field_unlimited[und][1][value]' => -1, - ); - $this->drupalPost('test-entity/nested/1/2', $edit, t('Save')); - $this->assertRaw(t('%label does not accept the value -1', array('%label' => 'Unlimited field')), t('Entity 1: the field validation error was reported.')); - $error_field = $this->xpath('//input[@id=:id and contains(@class, "error")]', array(':id' => 'edit-field-unlimited-und-1-value')); - $this->assertTrue($error_field, t('Entity 1: the error was flagged on the correct element.')); - $edit = array( - 'entity_2[field_unlimited][und][1][value]' => -1, - ); - $this->drupalPost('test-entity/nested/1/2', $edit, t('Save')); - $this->assertRaw(t('%label does not accept the value -1', array('%label' => 'Unlimited field')), t('Entity 2: the field validation error was reported.')); - $error_field = $this->xpath('//input[@id=:id and contains(@class, "error")]', array(':id' => 'edit-entity-2-field-unlimited-und-1-value')); - $this->assertTrue($error_field, t('Entity 2: the error was flagged on the correct element.')); - - // Test that reordering works on both entities. - $edit = array( - 'field_unlimited[und][0][_weight]' => 0, - 'field_unlimited[und][1][_weight]' => -1, - 'entity_2[field_unlimited][und][0][_weight]' => 0, - 'entity_2[field_unlimited][und][1][_weight]' => -1, - ); - $this->drupalPost('test-entity/nested/1/2', $edit, t('Save')); - field_cache_clear(); - $this->assertFieldValues($entity_1, 'field_unlimited', LANGUAGE_NONE, array(3, 2)); - $this->assertFieldValues($entity_2, 'field_unlimited', LANGUAGE_NONE, array(13, 12)); - - // Test the 'add more' buttons. Only AJAX submission is tested, because - // the two 'add more' buttons present in the form have the same #value, - // which confuses drupalPost(). - // 'Add more' button in the first entity: - $this->drupalGet('test-entity/nested/1/2'); - $this->drupalPostAJAX(NULL, array(), 'field_unlimited_add_more'); - $this->assertFieldByName('field_unlimited[und][0][value]', 3, t('Entity 1: field_unlimited value 0 appears correctly is the form.')); - $this->assertFieldByName('field_unlimited[und][1][value]', 2, t('Entity 1: field_unlimited value 1 appears correctly is the form.')); - $this->assertFieldByName('field_unlimited[und][2][value]', '', t('Entity 1: field_unlimited value 2 appears correctly is the form.')); - $this->assertFieldByName('field_unlimited[und][3][value]', '', t('Entity 1: an empty widget was added for field_unlimited value 3.')); - // 'Add more' button in the first entity (changing field values): - $edit = array( - 'entity_2[field_unlimited][und][0][value]' => 13, - 'entity_2[field_unlimited][und][1][value]' => 14, - 'entity_2[field_unlimited][und][2][value]' => 15, - ); - $this->drupalPostAJAX(NULL, $edit, 'entity_2_field_unlimited_add_more'); - $this->assertFieldByName('entity_2[field_unlimited][und][0][value]', 13, t('Entity 2: field_unlimited value 0 appears correctly is the form.')); - $this->assertFieldByName('entity_2[field_unlimited][und][1][value]', 14, t('Entity 2: field_unlimited value 1 appears correctly is the form.')); - $this->assertFieldByName('entity_2[field_unlimited][und][2][value]', 15, t('Entity 2: field_unlimited value 2 appears correctly is the form.')); - $this->assertFieldByName('entity_2[field_unlimited][und][3][value]', '', t('Entity 2: an empty widget was added for field_unlimited value 3.')); - // Save the form and check values are saved correclty. - $this->drupalPost(NULL, array(), t('Save')); - field_cache_clear(); - $this->assertFieldValues($entity_1, 'field_unlimited', LANGUAGE_NONE, array(3, 2)); - $this->assertFieldValues($entity_2, 'field_unlimited', LANGUAGE_NONE, array(13, 14, 15)); + // Add two instances on the 'test_bundle' + field_create_field($this->field_single); + field_create_field($this->field_unlimited); + $this->instance['field_name'] = 'field_single'; + $this->instance['label'] = 'Single field'; + field_create_instance($this->instance); + $this->instance['field_name'] = 'field_unlimited'; + $this->instance['label'] = 'Unlimited field'; + field_create_instance($this->instance); + + // Create two entities. + $entity_1 = field_test_create_stub_entity(1, 1); + $entity_1->is_new = TRUE; + $entity_1->field_single[LANGUAGE_NONE][] = array('value' => 0); + $entity_1->field_unlimited[LANGUAGE_NONE][] = array('value' => 1); + field_test_entity_save($entity_1); + + $entity_2 = field_test_create_stub_entity(2, 2); + $entity_2->is_new = TRUE; + $entity_2->field_single[LANGUAGE_NONE][] = array('value' => 10); + $entity_2->field_unlimited[LANGUAGE_NONE][] = array('value' => 11); + field_test_entity_save($entity_2); + + // Display the 'combined form'. + $this->drupalGet('test-entity/nested/1/2'); + $this->assertFieldByName('field_single[und][0][value]', 0, t('Entity 1: field_single value appears correctly is the form.')); + $this->assertFieldByName('field_unlimited[und][0][value]', 1, t('Entity 1: field_unlimited value 0 appears correctly is the form.')); + $this->assertFieldByName('entity_2[field_single][und][0][value]', 10, t('Entity 2: field_single value appears correctly is the form.')); + $this->assertFieldByName('entity_2[field_unlimited][und][0][value]', 11, t('Entity 2: field_unlimited value 0 appears correctly is the form.')); + + // Submit the form and check that the entities are updated accordingly. + $edit = array( + 'field_single[und][0][value]' => 1, + 'field_unlimited[und][0][value]' => 2, + 'field_unlimited[und][1][value]' => 3, + 'entity_2[field_single][und][0][value]' => 11, + 'entity_2[field_unlimited][und][0][value]' => 12, + 'entity_2[field_unlimited][und][1][value]' => 13, + ); + $this->drupalPost(NULL, $edit, t('Save')); + field_cache_clear(); + $entity_1 = field_test_create_stub_entity(1); + $entity_2 = field_test_create_stub_entity(2); + $this->assertFieldValues($entity_1, 'field_single', LANGUAGE_NONE, array(1)); + $this->assertFieldValues($entity_1, 'field_unlimited', LANGUAGE_NONE, array(2, 3)); + $this->assertFieldValues($entity_2, 'field_single', LANGUAGE_NONE, array(11)); + $this->assertFieldValues($entity_2, 'field_unlimited', LANGUAGE_NONE, array(12, 13)); + + // Submit invalid values and check that errors are reported on the + // correct widgets. + $edit = array( + 'field_unlimited[und][1][value]' => -1, + ); + $this->drupalPost('test-entity/nested/1/2', $edit, t('Save')); + $this->assertRaw(t('%label does not accept the value -1', array('%label' => 'Unlimited field')), t('Entity 1: the field validation error was reported.')); + $error_field = $this->xpath('//input[@id=:id and contains(@class, "error")]', array(':id' => 'edit-field-unlimited-und-1-value')); + $this->assertTrue($error_field, t('Entity 1: the error was flagged on the correct element.')); + $edit = array( + 'entity_2[field_unlimited][und][1][value]' => -1, + ); + $this->drupalPost('test-entity/nested/1/2', $edit, t('Save')); + $this->assertRaw(t('%label does not accept the value -1', array('%label' => 'Unlimited field')), t('Entity 2: the field validation error was reported.')); + $error_field = $this->xpath('//input[@id=:id and contains(@class, "error")]', array(':id' => 'edit-entity-2-field-unlimited-und-1-value')); + $this->assertTrue($error_field, t('Entity 2: the error was flagged on the correct element.')); + + // Test that reordering works on both entities. + $edit = array( + 'field_unlimited[und][0][_weight]' => 0, + 'field_unlimited[und][1][_weight]' => -1, + 'entity_2[field_unlimited][und][0][_weight]' => 0, + 'entity_2[field_unlimited][und][1][_weight]' => -1, + ); + $this->drupalPost('test-entity/nested/1/2', $edit, t('Save')); + field_cache_clear(); + $this->assertFieldValues($entity_1, 'field_unlimited', LANGUAGE_NONE, array(3, 2)); + $this->assertFieldValues($entity_2, 'field_unlimited', LANGUAGE_NONE, array(13, 12)); + + // Test the 'add more' buttons. Only Ajax submission is tested, because + // the two 'add more' buttons present in the form have the same #value, + // which confuses drupalPost(). + // 'Add more' button in the first entity: + $this->drupalGet('test-entity/nested/1/2'); + $this->drupalPostAJAX(NULL, array(), 'field_unlimited_add_more'); + $this->assertFieldByName('field_unlimited[und][0][value]', 3, t('Entity 1: field_unlimited value 0 appears correctly is the form.')); + $this->assertFieldByName('field_unlimited[und][1][value]', 2, t('Entity 1: field_unlimited value 1 appears correctly is the form.')); + $this->assertFieldByName('field_unlimited[und][2][value]', '', t('Entity 1: field_unlimited value 2 appears correctly is the form.')); + $this->assertFieldByName('field_unlimited[und][3][value]', '', t('Entity 1: an empty widget was added for field_unlimited value 3.')); + // 'Add more' button in the first entity (changing field values): + $edit = array( + 'entity_2[field_unlimited][und][0][value]' => 13, + 'entity_2[field_unlimited][und][1][value]' => 14, + 'entity_2[field_unlimited][und][2][value]' => 15, + ); + $this->drupalPostAJAX(NULL, $edit, 'entity_2_field_unlimited_add_more'); + $this->assertFieldByName('entity_2[field_unlimited][und][0][value]', 13, t('Entity 2: field_unlimited value 0 appears correctly is the form.')); + $this->assertFieldByName('entity_2[field_unlimited][und][1][value]', 14, t('Entity 2: field_unlimited value 1 appears correctly is the form.')); + $this->assertFieldByName('entity_2[field_unlimited][und][2][value]', 15, t('Entity 2: field_unlimited value 2 appears correctly is the form.')); + $this->assertFieldByName('entity_2[field_unlimited][und][3][value]', '', t('Entity 2: an empty widget was added for field_unlimited value 3.')); + // Save the form and check values are saved correclty. + $this->drupalPost(NULL, array(), t('Save')); + field_cache_clear(); + $this->assertFieldValues($entity_1, 'field_unlimited', LANGUAGE_NONE, array(3, 2)); + $this->assertFieldValues($entity_2, 'field_unlimited', LANGUAGE_NONE, array(13, 14, 15)); } } @@ -1827,7 +1875,7 @@ class FieldDisplayAPITestCase extends FieldTestCase { $item = $this->entity->{$this->field_name}[LANGUAGE_NONE][$delta]; $output = field_view_value('test_entity', $this->entity, $this->field_name, $item, $display); $this->drupalSetContent(drupal_render($output)); - $this->assertText($setting . '|0:' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); + $this->assertText($setting . '|0:' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); } // Check that prepare_view steps are invoked. @@ -1843,7 +1891,7 @@ class FieldDisplayAPITestCase extends FieldTestCase { $item = $this->entity->{$this->field_name}[LANGUAGE_NONE][$delta]; $output = field_view_value('test_entity', $this->entity, $this->field_name, $item, $display); $this->drupalSetContent(drupal_render($output)); - $this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); + $this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); } // View mode: check that display settings specified in the instance are @@ -2642,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. @@ -2667,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) { @@ -2681,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))); + } + } } /** @@ -2880,7 +2958,7 @@ class FieldBulkDeleteTestCase extends FieldTestCase { public static function getInfo() { return array( 'name' => 'Field bulk delete tests', - 'description'=> 'Bulk delete fields and instances, and clean up afterwards.', + 'description' => 'Bulk delete fields and instances, and clean up afterwards.', 'group' => 'Field API', ); } @@ -3127,7 +3205,7 @@ class EntityPropertiesTestCase extends FieldTestCase { public static function getInfo() { return array( 'name' => 'Entity properties', - 'description'=> 'Tests entity properties.', + 'description' => 'Tests entity properties.', 'group' => 'Entity API', ); } diff --git a/modules/field/tests/field_test.entity.inc b/modules/field/tests/field_test.entity.inc index 4273dd95f..b7c70a677 100644 --- a/modules/field/tests/field_test.entity.inc +++ b/modules/field/tests/field_test.entity.inc @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file diff --git a/modules/field/tests/field_test.field.inc b/modules/field/tests/field_test.field.inc index d11bc2fd5..b8a2939d6 100644 --- a/modules/field/tests/field_test.field.inc +++ b/modules/field/tests/field_test.field.inc @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file diff --git a/modules/field/tests/field_test.info b/modules/field/tests/field_test.info index 15fb06542..6d117068c 100644 --- a/modules/field/tests/field_test.info +++ b/modules/field/tests/field_test.info @@ -1,4 +1,3 @@ -;$Id$ name = "Field API Test" description = "Support module for the Field API tests." core = 7.x diff --git a/modules/field/tests/field_test.install b/modules/field/tests/field_test.install index 268d271c7..595756110 100644 --- a/modules/field/tests/field_test.install +++ b/modules/field/tests/field_test.install @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file diff --git a/modules/field/tests/field_test.module b/modules/field/tests/field_test.module index 6e068fe33..9e2fef62c 100644 --- a/modules/field/tests/field_test.module +++ b/modules/field/tests/field_test.module @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file @@ -89,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/field/tests/field_test.storage.inc b/modules/field/tests/field_test.storage.inc index 43f1c4b49..3ca322dd7 100644 --- a/modules/field/tests/field_test.storage.inc +++ b/modules/field/tests/field_test.storage.inc @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file @@ -288,7 +287,7 @@ function field_test_field_storage_query($field_id, $conditions, $count, &$cursor case '<=': case '>': case '>=': - eval('$match = $match && '. $row->{$column} . ' ' . $operator . ' '. $value); + eval('$match = $match && ' . $row->{$column} . ' ' . $operator . ' '. $value); break; case 'IN': $match = $match && in_array($row->{$column}, $value); diff --git a/modules/field/theme/field-rtl.css b/modules/field/theme/field-rtl.css index 814db8929..5d35a86a1 100644 --- a/modules/field/theme/field-rtl.css +++ b/modules/field/theme/field-rtl.css @@ -1,4 +1,3 @@ -/* $Id$ */ form .field-multiple-table th.field-label { padding-right: 0; diff --git a/modules/field/theme/field.css b/modules/field/theme/field.css index 9323b8b82..9eba32f0b 100644 --- a/modules/field/theme/field.css +++ b/modules/field/theme/field.css @@ -1,4 +1,3 @@ -/* $Id$ */ /* Field display */ .field .field-label { diff --git a/modules/field/theme/field.tpl.php b/modules/field/theme/field.tpl.php index 8f317c93b..e4cd85cd0 100644 --- a/modules/field/theme/field.tpl.php +++ b/modules/field/theme/field.tpl.php @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file field.tpl.php |