Commit 9cf81913 authored by Crell's avatar Crell

Merge remote-tracking branch 'upstream/8.x' into kernel

parents c96c3fca 48f271b6
......@@ -17,8 +17,8 @@ function config_get_config_directory() {
global $config_directory_name;
if ($test_prefix = drupal_valid_test_ua()) {
$path = conf_path() . '/files/simpletest/config_' . $test_prefix;
file_prepare_directory($path, FILE_CREATE_DIRECTORY);
// @see DrupalWebTestCase::setUp()
$path = conf_path() . '/files/simpletest/' . substr($test_prefix, 10) . '/config';
}
else {
$path = conf_path() . '/files/' . $config_directory_name;
......
......@@ -3361,7 +3361,7 @@ function form_process_tableselect($element) {
$value = is_array($element['#value']) ? $element['#value'] : array();
}
else {
// Advanced selection behaviour make no sense for radios.
// Advanced selection behavior makes no sense for radios.
$element['#js_select'] = FALSE;
}
......
......@@ -59,7 +59,7 @@
* means that assigning an offset via arrayAccess will only apply while the
* object is in scope and will not be written back to the persistent cache.
* This follows a similar pattern to static vs. persistent caching in
* procedural code. Extending classes may wish to alter this behaviour, for
* procedural code. Extending classes may wish to alter this behavior, for
* example by overriding offsetSet() and adding an automatic call to persist().
*
* @see SchemaCache
......
......@@ -37,87 +37,83 @@ function field_default_form($entity_type, $entity, $field, $instance, $langcode,
// Collect widget elements.
$elements = array();
if (field_access('edit', $field, $entity_type, $entity)) {
// Store field information in $form_state.
if (!field_form_get_state($parents, $field_name, $langcode, $form_state)) {
$field_state = array(
'field' => $field,
'instance' => $instance,
'items_count' => count($items),
'array_parents' => array(),
'errors' => array(),
);
field_form_set_state($parents, $field_name, $langcode, $form_state, $field_state);
}
// If field module handles multiple values for this form element, and we
// are displaying an individual element, process the multiple value form.
if (!isset($get_delta) && field_behaviors_widget('multiple values', $instance) == FIELD_BEHAVIOR_DEFAULT) {
$elements = field_multiple_value_form($field, $instance, $langcode, $items, $form, $form_state);
}
// If the widget is handling multiple values (e.g Options), or if we are
// displaying an individual element, just get a single form element and
// make it the $delta value.
else {
$delta = isset($get_delta) ? $get_delta : 0;
$function = $instance['widget']['module'] . '_field_widget_form';
if (function_exists($function)) {
$element = array(
'#entity_type' => $instance['entity_type'],
'#bundle' => $instance['bundle'],
'#field_name' => $field_name,
'#language' => $langcode,
'#field_parents' => $parents,
'#columns' => array_keys($field['columns']),
'#title' => check_plain($instance['label']),
'#description' => field_filter_xss($instance['description']),
// Only the first widget should be required.
'#required' => $delta == 0 && $instance['required'],
'#delta' => $delta,
// Store field information in $form_state.
if (!field_form_get_state($parents, $field_name, $langcode, $form_state)) {
$field_state = array(
'field' => $field,
'instance' => $instance,
'items_count' => count($items),
'array_parents' => array(),
'errors' => array(),
);
field_form_set_state($parents, $field_name, $langcode, $form_state, $field_state);
}
// If field module handles multiple values for this form element, and we are
// displaying an individual element, process the multiple value form.
if (!isset($get_delta) && field_behaviors_widget('multiple values', $instance) == FIELD_BEHAVIOR_DEFAULT) {
$elements = field_multiple_value_form($field, $instance, $langcode, $items, $form, $form_state);
}
// If the widget is handling multiple values (e.g Options), or if we are
// displaying an individual element, just get a single form element and make
// it the $delta value.
else {
$delta = isset($get_delta) ? $get_delta : 0;
$function = $instance['widget']['module'] . '_field_widget_form';
if (function_exists($function)) {
$element = array(
'#entity_type' => $instance['entity_type'],
'#bundle' => $instance['bundle'],
'#field_name' => $field_name,
'#language' => $langcode,
'#field_parents' => $parents,
'#columns' => array_keys($field['columns']),
'#title' => check_plain($instance['label']),
'#description' => field_filter_xss($instance['description']),
// Only the first widget should be required.
'#required' => $delta == 0 && $instance['required'],
'#delta' => $delta,
);
if ($element = $function($form, $form_state, $field, $instance, $langcode, $items, $delta, $element)) {
// Allow modules to alter the field widget form element.
$context = array(
'form' => $form,
'field' => $field,
'instance' => $instance,
'langcode' => $langcode,
'items' => $items,
'delta' => $delta,
);
if ($element = $function($form, $form_state, $field, $instance, $langcode, $items, $delta, $element)) {
// Allow modules to alter the field widget form element.
$context = array(
'form' => $form,
'field' => $field,
'instance' => $instance,
'langcode' => $langcode,
'items' => $items,
'delta' => $delta,
);
drupal_alter(array('field_widget_form', 'field_widget_' . $instance['widget']['type'] . '_form'), $element, $form_state, $context);
// If we're processing a specific delta value for a field where the
// field module handles multiples, set the delta in the result.
// For fields that handle their own processing, we can't make
// assumptions about how the field is structured, just merge in the
// returned element.
if (field_behaviors_widget('multiple values', $instance) == FIELD_BEHAVIOR_DEFAULT) {
$elements[$delta] = $element;
}
else {
$elements = $element;
}
drupal_alter(array('field_widget_form', 'field_widget_' . $instance['widget']['type'] . '_form'), $element, $form_state, $context);
// If we're processing a specific delta value for a field where the
// field module handles multiples, set the delta in the result.
// For fields that handle their own processing, we can't make
// assumptions about how the field is structured, just merge in the
// returned element.
if (field_behaviors_widget('multiple values', $instance) == FIELD_BEHAVIOR_DEFAULT) {
$elements[$delta] = $element;
}
else {
$elements = $element;
}
}
}
}
if ($elements) {
// Also aid in theming of field widgets by rendering a classified
// container.
$addition[$field_name] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array(
'field-type-' . drupal_html_class($field['type']),
'field-name-' . drupal_html_class($field_name),
'field-widget-' . drupal_html_class($instance['widget']['type']),
),
// Also aid in theming of field widgets by rendering a classified container.
$addition[$field_name] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array(
'field-type-' . drupal_html_class($field['type']),
'field-name-' . drupal_html_class($field_name),
'field-widget-' . drupal_html_class($instance['widget']['type']),
),
'#weight' => $instance['widget']['weight'],
);
}
),
'#weight' => $instance['widget']['weight'],
);
// Populate the 'array_parents' information in $form_state['field'] after
// the form is built, so that we catch changes in the form structure performed
......@@ -133,6 +129,7 @@ function field_default_form($entity_type, $entity, $field, $instance, $langcode,
// when $langcode is unknown.
'#language' => $langcode,
$langcode => $elements,
'#access' => field_access('edit', $field, $entity_type, $entity),
);
return $addition;
......@@ -358,31 +355,33 @@ function field_default_form_errors($entity_type, $entity, $field, $instance, $la
$field_state = field_form_get_state($form['#parents'], $field['field_name'], $langcode, $form_state);
if (!empty($field_state['errors'])) {
$function = $instance['widget']['module'] . '_field_widget_error';
$function_exists = function_exists($function);
// Locate the correct element in the the form.
// Locate the correct element in the form.
$element = drupal_array_get_nested_value($form_state['complete_form'], $field_state['array_parents']);
$multiple_widget = field_behaviors_widget('multiple values', $instance) != FIELD_BEHAVIOR_DEFAULT;
foreach ($field_state['errors'] as $delta => $delta_errors) {
// For multiple single-value widgets, pass errors by delta.
// For a multiple-value widget, all errors are passed to the main widget.
$error_element = $multiple_widget ? $element : $element[$delta];
foreach ($delta_errors as $error) {
if ($function_exists) {
$function($error_element, $error, $form, $form_state);
}
else {
// Make sure that errors are reported (even incorrectly flagged) if
// the widget module fails to implement hook_field_widget_error().
form_error($error_element, $error['error']);
// Only set errors if the element is accessible.
if (!isset($element['#access']) || $element['#access']) {
$function = $instance['widget']['module'] . '_field_widget_error';
$function_exists = function_exists($function);
$multiple_widget = field_behaviors_widget('multiple values', $instance) != FIELD_BEHAVIOR_DEFAULT;
foreach ($field_state['errors'] as $delta => $delta_errors) {
// For multiple single-value widgets, pass errors by delta.
// For a multiple-value widget, pass all errors to the main widget.
$error_element = $multiple_widget ? $element : $element[$delta];
foreach ($delta_errors as $error) {
if ($function_exists) {
$function($error_element, $error, $form, $form_state);
}
else {
// Make sure that errors are reported (even incorrectly flagged) if
// the widget module fails to implement hook_field_widget_error().
form_error($error_element, $error['error']);
}
}
}
// Reinitialize the errors list for the next submit.
$field_state['errors'] = array();
field_form_set_state($form['#parents'], $field['field_name'], $langcode, $form_state, $field_state);
}
// Reinitialize the errors list for the next submit.
$field_state['errors'] = array();
field_form_set_state($form['#parents'], $field['field_name'], $langcode, $form_state, $field_state);
}
}
......
......@@ -1650,6 +1650,18 @@ class FieldFormTestCase extends FieldTestCase {
$langcode = LANGUAGE_NOT_SPECIFIED;
// Test that the form structure includes full information for each delta
// apart from #access.
$entity_type = 'test_entity';
$entity = field_test_create_stub_entity(0, 0, $this->instance['bundle']);
$form = array();
$form_state = form_state_defaults();
field_attach_form($entity_type, $entity, $form, $form_state);
$this->assertEqual($form[$field_name_no_access][$langcode][0]['value']['#entity_type'], $entity_type, 'The correct entity type is set in the field structure.');
$this->assertFalse($form[$field_name_no_access]['#access'], 'Field #access is FALSE for the field without edit access.');
// Display creation form.
$this->drupalGet('test-entity/add/test-bundle');
$this->assertNoFieldByName("{$field_name_no_access}[$langcode][0][value]", '', t('Widget is not displayed if field access is denied.'));
......
......@@ -1111,7 +1111,7 @@ function filter_dom_serialize_escape_cdata_element($dom_document, $dom_element,
$embed_suffix = "\n{$comment_start}--><!]]>{$comment_end}\n";
// Prevent invalid cdata escaping as this would throw a DOM error.
// This is the same behaviour as found in libxml2.
// This is the same behavior as found in libxml2.
// Related W3C standard: http://www.w3.org/TR/REC-xml/#dt-cdsection
// Fix explanation: http://en.wikipedia.org/wiki/CDATA#Nesting
$data = str_replace(']]>', ']]]]><![CDATA[>', $node->data);
......
......@@ -3094,7 +3094,7 @@ function node_access($op, $node, $account = NULL) {
return $result;
}
elseif (is_object($node) && $op == 'view' && $node->status) {
// If no modules implement hook_node_grants(), the default behaviour is to
// If no modules implement hook_node_grants(), the default behavior is to
// allow all users to view published nodes, so reflect that here.
$rights[$account->uid][$cid][$op] = TRUE;
return TRUE;
......
......@@ -1354,7 +1354,8 @@ protected function setUp() {
// Create and set a new configuration directory and signature key.
// The child site automatically adjusts the global $config_directory_name to
// a test-prefix-specific directory within the public files directory.
$GLOBALS['config_directory_name'] = 'simpletest/config_' . $this->databasePrefix;
// @see config_get_config_directory()
$GLOBALS['config_directory_name'] = 'simpletest/' . substr($this->databasePrefix, 10) . '/config';
$this->configFileDirectory = $this->originalFileDirectory . '/' . $GLOBALS['config_directory_name'];
file_prepare_directory($this->configFileDirectory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
$GLOBALS['config_signature_key'] = drupal_hash_base64(drupal_random_bytes(55));
......@@ -1547,9 +1548,6 @@ protected function tearDown() {
// Delete temporary files directory.
file_unmanaged_delete_recursive($this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10));
// Delete temporary config files directory.
file_unmanaged_delete_recursive($this->originalFileDirectory . '/simpletest/config_simpletest' . substr($this->databasePrefix, 10));
// Remove all prefixed tables (all the tables in the schema).
$schema = drupal_get_schema(NULL, TRUE);
foreach ($schema as $name => $table) {
......
......@@ -813,12 +813,12 @@ class FormsElementsLabelsTestCase extends DrupalWebTestCase {
$this->assertTrue(isset($elements[0]), t("Label 0 found radios."));
// Exercise various defaults for checkboxes and modifications to ensure
// appropriate override and correct behaviour.
// appropriate override and correct behavior.
$elements = $this->xpath('//input[@id="edit-form-checkbox-test"]/following-sibling::label[@for="edit-form-checkbox-test" and @class="option"]');
$this->assertTrue(isset($elements[0]), t("Label follows field and label option class correct for a checkbox by default."));
// Exercise various defaults for textboxes and modifications to ensure
// appropriate override and correct behaviour.
// appropriate override and correct behavior.
$elements = $this->xpath('//label[@for="edit-form-textfield-test-title-and-required"]/child::abbr[@class="form-required"]/parent::*/following-sibling::input[@id="edit-form-textfield-test-title-and-required"]');
$this->assertTrue(isset($elements[0]), t("Label precedes textfield, with required marker inside label."));
......
......@@ -1670,7 +1670,7 @@ class UserBlocksUnitTests extends DrupalWebTestCase {
}
/**
* Test case to test user_save() behaviour.
* Tests user_save() behavior.
*/
class UserSaveTestCase extends DrupalWebTestCase {
......@@ -1759,7 +1759,7 @@ class UserCreateTestCase extends DrupalWebTestCase {
}
/**
* Test case to test user_save() behaviour.
* Tests the user edit form.
*/
class UserEditTestCase extends DrupalWebTestCase {
......
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