diff --git a/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php index c9ad6f8..e1fe0af 100644 --- a/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php @@ -80,7 +80,7 @@ public function onViewRenderArray(GetResponseForControllerResultEvent $event) { // Render the controller result into a response if it's a render array. if (is_array($result)) { - $wrapper = $request->query->get(static::WRAPPER_ENVELOPE, 'html'); + $wrapper = $request->query->get(static::WRAPPER_ENVELOPE, $request->getRequestFormat()); if (isset($this->mainContentRenderers[$wrapper])) { $renderer = $this->classResolver->getInstanceFromDefinition($this->mainContentRenderers[$wrapper]); $event->setResponse($renderer->renderResponse($result, $request, $this->routeMatch)); diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php index 5b8b109..9c014e8 100644 --- a/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -1786,11 +1786,6 @@ protected function drupalPostForm($path, $edit, $submit, array $options = array( * @see ajax.js */ protected function drupalPostAjaxForm($path, $edit, $triggering_element, $ajax_path = NULL, array $options = array(), array $headers = array(), $form_html_id = NULL, $ajax_settings = NULL) { - if (isset($options['query'][MainContentViewSubscriber::WRAPPER_ENVELOPE])) { - $original_wrapper = $options['query'][MainContentViewSubscriber::WRAPPER_ENVELOPE]; - unset($options['query'][MainContentViewSubscriber::WRAPPER_ENVELOPE]); - } - // Get the content of the initial page prior to calling drupalPostForm(), // since drupalPostForm() replaces $this->content. if (isset($path)) { @@ -1799,11 +1794,8 @@ protected function drupalPostAjaxForm($path, $edit, $triggering_element, $ajax_p $content = $this->content; $drupal_settings = $this->drupalSettings; - if (isset($original_wrapper)) { - $options['query'][MainContentViewSubscriber::WRAPPER_ENVELOPE] = $original_wrapper; - } - else { - $options['query'][MainContentViewSubscriber::WRAPPER_ENVELOPE] = 'drupal_ajax'; + if (!preg_grep('/^Accept:/', $headers)) { + $headers[] = 'Accept: application/vnd.drupal-ajax'; } // Get the Ajax settings bound to the triggering element. @@ -1843,9 +1835,8 @@ protected function drupalPostAjaxForm($path, $edit, $triggering_element, $ajax_p // Unless a particular path is specified, use the one specified by the // Ajax settings, or else 'system/ajax'. if (!isset($ajax_path)) { - $ajax_path = isset($ajax_settings['url']) ? preg_replace('/^' . preg_quote($GLOBALS['base_path'], '/') . '/', '', $ajax_settings['url']) : 'system/ajax'; + $ajax_path = isset($ajax_settings['url']) ? $ajax_settings['url'] : 'system/ajax'; } - $ajax_path = $this->container->get('url_generator')->generateFromPath($ajax_path, $options); // Submit the POST request. $return = Json::decode($this->drupalPostForm(NULL, $edit, array('path' => $ajax_path, 'triggering_element' => $triggering_element), $options, $headers, $form_html_id, $extra_post));