diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 7cf7932..06d7554 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -773,94 +773,6 @@ function _drupal_set_preferred_header_name($name = NULL) { } /** - * Sends the HTTP response headers that were previously set, adding defaults. - * - * Headers are set in drupal_add_http_header(). Default headers are not set - * if they have been replaced or unset using drupal_add_http_header(). - * - * @param array $default_headers - * (optional) An array of headers as name/value pairs. - * @param bool $only_default - * (optional) If TRUE and headers have already been sent, send only the - * specified headers. - * - * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. - * See https://drupal.org/node/2181523. - */ -function drupal_send_headers($default_headers = array(), $only_default = FALSE) { - $headers_sent = &drupal_static(__FUNCTION__, FALSE); - $headers = drupal_get_http_header(); - if ($only_default && $headers_sent) { - $headers = array(); - } - $headers_sent = TRUE; - - $header_names = _drupal_set_preferred_header_name(); - foreach ($default_headers as $name => $value) { - $name_lower = strtolower($name); - if (!isset($headers[$name_lower])) { - $headers[$name_lower] = $value; - $header_names[$name_lower] = $name; - } - } - foreach ($headers as $name_lower => $value) { - if ($name_lower == 'status') { - header($_SERVER['SERVER_PROTOCOL'] . ' ' . $value); - } - // Skip headers that have been unset. - elseif ($value !== FALSE) { - header($header_names[$name_lower] . ': ' . $value); - } - } -} - -/** - * Sets HTTP headers in preparation for a page response. - * - * Authenticated users are always given a 'no-cache' header, and will fetch a - * fresh page on every request. This prevents authenticated users from seeing - * locally cached pages. - * - * Also give each page a unique ETag. This will force clients to include both - * an If-Modified-Since header and an If-None-Match header when doing - * conditional requests for the page (required by RFC 2616, section 13.3.4), - * making the validation more robust. This is a workaround for a bug in Mozilla - * Firefox that is triggered when Drupal's caching is enabled and the user - * accesses Drupal via an HTTP proxy (see - * https://bugzilla.mozilla.org/show_bug.cgi?id=269303): When an authenticated - * user requests a page, and then logs out and requests the same page again, - * Firefox may send a conditional request based on the page that was cached - * locally when the user was logged in. If this page did not have an ETag - * header, the request only contains an If-Modified-Since header. The date will - * be recent, because with authenticated users the Last-Modified header always - * refers to the time of the request. If the user accesses Drupal via a proxy - * server, and the proxy already has a cached copy of the anonymous page with an - * older Last-Modified date, the proxy may respond with 304 Not Modified, making - * the client think that the anonymous and authenticated pageviews are - * identical. - * - * @see drupal_page_set_cache() - * - * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. - * See https://drupal.org/node/2181523. - */ -function drupal_page_header() { - $headers_sent = &drupal_static(__FUNCTION__, FALSE); - if ($headers_sent) { - return TRUE; - } - $headers_sent = TRUE; - - $default_headers = array( - 'Expires' => 'Sun, 19 Nov 1978 05:00:00 GMT', - 'Last-Modified' => gmdate(DATE_RFC1123, REQUEST_TIME), - 'Cache-Control' => 'no-cache, must-revalidate, post-check=0, pre-check=0', - 'ETag' => '"' . REQUEST_TIME . '"', - ); - drupal_send_headers($default_headers); -} - -/** * Sets HTTP headers in preparation for a cached page response. * * The headers allow as much as possible in proxies and browsers without any diff --git a/core/includes/common.inc b/core/includes/common.inc index 0336161..1be6731 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -3225,8 +3225,6 @@ function _drupal_bootstrap_full($skip = FALSE) { * The response body. * @return * The cached object or NULL if the page cache was not set. - * - * @see drupal_page_header() */ function drupal_page_set_cache(Response $response, Request $request) { if (drupal_page_is_cacheable()) { @@ -4302,6 +4300,9 @@ function _drupal_render_process_post_render_cache(array &$elements) { $modified_elements = $elements; foreach ($elements['#post_render_cache'] as $callback => $options) { foreach ($elements['#post_render_cache'][$callback] as $token => $context) { + if (!is_callable($callback)) { + continue; + } // The advanced option, when setting #post_render_cache directly. if (is_numeric($token)) { $modified_elements = call_user_func_array($callback, array($modified_elements, $context)); diff --git a/core/includes/errors.inc b/core/includes/errors.inc index 56c276f..3bdd246 100644 --- a/core/includes/errors.inc +++ b/core/includes/errors.inc @@ -228,7 +228,7 @@ function _drupal_log_error($error, $fatal = FALSE) { '#title' => 'Error', '#markup' => $message, ); - install_display_output($output, $GLOBALS['install_state']); + $response = install_display_output($output, $GLOBALS['install_state']); } else { $output = array( @@ -236,11 +236,10 @@ function _drupal_log_error($error, $fatal = FALSE) { '#title' => 'Error', '#content' => $message, ); - $output = drupal_render($output); + $response = new Response($output, 500); + $response->setStatusCode(500, '500 Service unavailable (with message)'); } - $response = new Response($output, 500); - $response->setStatusCode(500, '500 Service unavailable (with message)'); // An exception must halt script execution. $response->send(); exit; diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 7f494c5..b7ed134 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -412,11 +412,9 @@ function install_begin_request(&$install_state) { $module_list = $module_handler->getModuleList(); if (!$module_handler->moduleExists('system')) { $module_list['system'] = 'core/modules/system/system.module'; - system_register('module', 'system', $module_list['system']); } if ($profile && !$module_handler->moduleExists($profile)) { $module_list[$profile] = $install_state['profiles'][$profile]->uri; - system_register('profile', $profile, $module_list[$profile]); } $module_handler->setModuleList($module_list); // After setting up a custom and finite module list in a custom low-level @@ -896,8 +894,6 @@ function install_display_output($output, $install_state) { // reached in case of an early installer error. drupal_maintenance_theme(); - drupal_page_header(); - // Prevent install.php from being indexed when installed in a sub folder. // robots.txt rules are not read if the site is within domain.com/subfolder // resulting in /subfolder/install.php being found through search engines. @@ -947,7 +943,23 @@ function install_display_output($output, $install_state) { $page->setBodyBottom(drupal_render($page_array['page_bottom'])); $page->setContent(drupal_render($page_array)); - print \Drupal::service('html_page_renderer')->render($page); + $response = new Response(\Drupal::service('html_page_renderer')->render($page)); + + // @todo Does it make sense to set all this HTTP heads for the installer? + // @todo This kind of information would be added by the + // FinishResponseSubscriber which could be used once we use a proper kernel + // in the installer. + $date = new DateTime('Sun, 19 Nov 1978 05:00:00 GMT'); + $response->setExpires($date); + $date = new DateTime('now'); + $response->setLastModified($date); + + $response->headers->set('Cache-Control', 'no-cache, must-revalidate, post-check=0, pre-check=0'); + $response->headers->set('ETag', '"' . REQUEST_TIME . '"'); + + $response->send(); + // @todo On the longrun there should be a single place which calls send on the + // response. exit; }