core/authorize.php | 2 +- core/includes/batch.inc | 4 ++-- core/includes/errors.inc | 4 ++-- core/includes/install.core.inc | 4 ++-- .../Core/EventSubscriber/HtmlResponseSubscriber.php | 15 +++++++++------ core/lib/Drupal/Core/Render/BareHtmlPageRenderer.php | 4 ++-- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/core/authorize.php b/core/authorize.php index 4d9df40..a3d33c7 100644 --- a/core/authorize.php +++ b/core/authorize.php @@ -166,7 +166,7 @@ function authorize_access_allowed(Request $request) { '#show_messages' => $show_messages, ))); - // Prepare attachments, because this does not go the usual way via the + // Process attachments, because this does not go the usual way via the // Symfony chain, but is sent directly. $bare_html_page_renderer->prepareAttachments($response); diff --git a/core/includes/batch.inc b/core/includes/batch.inc index 8ac05b8..f7d6870 100644 --- a/core/includes/batch.inc +++ b/core/includes/batch.inc @@ -146,9 +146,9 @@ function _batch_progress_page() { // Use a HtmlResponse to process the attachments. $response = new HtmlResponse($content); - // Prepare attachments, because this does not go the usual way via the + // Process attachments, because this does not go the usual way via the // Symfony chain, but is sent directly. - $bare_html_page_renderer->prepareAttachments($response); + $bare_html_page_renderer->processAttachments($response); // Just use the content of the response. $fallback = $response->getContent(); diff --git a/core/includes/errors.inc b/core/includes/errors.inc index 8ed39b6..c1c3664 100644 --- a/core/includes/errors.inc +++ b/core/includes/errors.inc @@ -248,9 +248,9 @@ function _drupal_log_error($error, $fatal = FALSE) { $output = $bare_html_page_renderer->renderBarePage(['#markup' => $message], 'Error', 'maintenance_page'); $response = new HtmlResponse($output, 500); - // Prepare attachments, because this does not go the usual way via the + // Process attachments, because this does not go the usual way via the // Symfony chain, but is sent directly. - $bare_html_page_renderer->prepareAttachments($response); + $bare_html_page_renderer->processAttachments($response); $response->setStatusCode(500, '500 Service unavailable (with message)'); // An exception must halt script execution. diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 9f277b0..4ea52cc 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -996,9 +996,9 @@ function install_display_output($output, $install_state) { $response->headers->add($default_headers); $response->setContent($bare_html_page_renderer->renderBarePage($output, $output['#title'], 'install_page', $regions)); - // Prepare attachments, because this does not go the usual way via the + // Process attachments, because this does not go the usual way via the // Symfony chain, but is sent directly. - $bare_html_page_renderer->prepareAttachments($response); + $bare_html_page_renderer->processAttachments($response); $response->send(); exit; diff --git a/core/lib/Drupal/Core/EventSubscriber/HtmlResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/HtmlResponseSubscriber.php index 69fc027..b2afa77 100644 --- a/core/lib/Drupal/Core/EventSubscriber/HtmlResponseSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/HtmlResponseSubscriber.php @@ -111,7 +111,7 @@ public function onRespond(FilterResponseEvent $event) { } /** - * Prorcess attachments contained in a HtmlResponse. + * Processes attachments contained in a HtmlResponse. * * This renders them into HTML markup and replaces the HTML response * placeholders in the content of the response. @@ -131,12 +131,13 @@ public function processAttachments(AttachmentsResponseInterface $response) { $variables = []; $variables += $this->processAssetLibraries($attached, $placeholders); + // Handle all non-asset attachments. This populates drupal_get_html_head() + // and drupal_get_http_header(). + $all_attached = ['#attached' => $attached]; + drupal_process_attached($all_attached); + // Get HTML head elements - if present. if (isset($placeholders['head'])) { - // Handle all non-asset attachments. - $all_attached = ['#attached' => $attached]; - drupal_process_attached($all_attached); - $variables['head'] = drupal_get_html_head(FALSE); } @@ -210,7 +211,9 @@ protected function processAssetLibraries(array $attached, array $placeholders) { protected function renderPlaceholders(AttachmentsResponseInterface $response, array $placeholders, array $variables) { $content = $response->getContent(); foreach ($placeholders as $type => $placeholder) { - $content = str_replace($placeholder, $this->renderer->renderPlain($variables[$type]), $content); + if (isset($variables[$type])) { + $content = str_replace($placeholder, $this->renderer->renderPlain($variables[$type]), $content); + } } $response->setContent($content); } diff --git a/core/lib/Drupal/Core/Render/BareHtmlPageRenderer.php b/core/lib/Drupal/Core/Render/BareHtmlPageRenderer.php index 98de48f..3ee4d26 100644 --- a/core/lib/Drupal/Core/Render/BareHtmlPageRenderer.php +++ b/core/lib/Drupal/Core/Render/BareHtmlPageRenderer.php @@ -85,8 +85,8 @@ public function renderBarePage(array $content, $title, $page_theme_property, arr /** * {@inheritdoc} */ - public function prepareAttachments(AttachmentsResponseInterface $response) { - $this->htmlResponseSubscriber->prepareAttachments($response); + public function processAttachments(AttachmentsResponseInterface $response) { + $this->htmlResponseSubscriber->processAttachments($response); } }