diff --git a/core/misc/ajax.js b/core/misc/ajax.js index 0309dc2..0d5bf44 100644 --- a/core/misc/ajax.js +++ b/core/misc/ajax.js @@ -407,8 +407,7 @@ else { ajax.options.url += '&'; } - // @todo Passing both always is kinda redicilous! - ajax.options.url += Drupal.ajax.AJAX_FORM_REQUEST + '=1&' + Drupal.ajax.WRAPPER_FORMAT + '=drupal_' + (element_settings.dialogType || 'ajax'); + ajax.options.url += Drupal.ajax.WRAPPER_FORMAT + '=drupal_' + (element_settings.dialogType || 'ajax'); // Bind the ajaxSubmit function to the element event. $(ajax.element).on(element_settings.event, function (event) { @@ -433,11 +432,6 @@ }; /** - * Request key for a form that was triggered via AJAX. - */ - Drupal.ajax.AJAX_FORM_REQUEST = 'ajax_form'; - - /** * URL query attribute to indicate the wrapper used to render a request. * * The wrapper format determines how the HTML is wrapped, for example in a diff --git a/core/modules/file/src/Element/ManagedFile.php b/core/modules/file/src/Element/ManagedFile.php index 3da9e42..5838e6c 100644 --- a/core/modules/file/src/Element/ManagedFile.php +++ b/core/modules/file/src/Element/ManagedFile.php @@ -130,9 +130,10 @@ public static function valueCallback(&$element, $input, FormStateInterface $form /** * #ajax callback for managed_file upload forms. * - * This ajax callback takes care about ensuring that there is no broken - * request due to too big files, as well as adding a class to the response - * that a new file got uploaded. + * This ajax callback takes care of the following things: + * - Ensures that broken requests due to too big files are caught. + * - Adds a class to the response to be able to highlight in the UI, that + * a new file got uploaded. * * @param array $form * The build form. @@ -149,21 +150,10 @@ public static function uploadAjaxCallback(&$form, FormStateInterface &$form_stat $renderer = \Drupal::service('renderer'); $form_parents = explode('/', $request->query->get('element_parents')); - $form_build_id = $request->query->get('form_build_id'); - $request_form_build_id = $request->request->get('form_build_id'); - - if (empty($request_form_build_id) || $form_build_id !== $request_form_build_id) { - // Invalid request. - drupal_set_message(t('An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (@size) that this server supports.', array('@size' => format_size(file_upload_max_size()))), 'error'); - $response = new AjaxResponse(); - $status_messages = array('#type' => 'status_messages'); - return $response->addCommand(new ReplaceCommand(NULL, $renderer->renderRoot($status_messages))); - } // Retrieve the element to be rendered. $form = NestedArray::getValue($form, $form_parents); - // Add the special Ajax class if a new file was added. $current_file_count = $form_state->get('file_upload_delta_initial'); if (isset($form['#file_upload_delta']) && $current_file_count < $form['#file_upload_delta']) { @@ -210,7 +200,6 @@ public static function processManagedFile(&$element, FormStateInterface $form_st 'options' => [ 'query' => [ 'element_parents' => implode('/', $element['#array_parents']), - 'form_build_id' => $complete_form['form_build_id']['#value'], ], ], 'wrapper' => $element['#id'] . '-ajax-wrapper', diff --git a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php index 08ea7b3..05ce286 100644 --- a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php +++ b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php @@ -410,7 +410,6 @@ public static function process($element, FormStateInterface $form_state, $form) $new_options = array( 'query' => array( 'element_parents' => implode('/', $parents), - 'form_build_id' => $form['form_build_id']['#value'], ), ); $field_element = NestedArray::getValue($form, $parents);