diff --git a/core/includes/gettext.inc b/core/includes/gettext.inc index 4e3b221..1ea55c5 100644 --- a/core/includes/gettext.inc +++ b/core/includes/gettext.inc @@ -7,6 +7,8 @@ * @todo Decouple these functions from Locale API and put to gettext_ namespace. */ +use Symfony\Component\HttpFoundation\Response; + /** * @defgroup locale-api-import-export Translation import/export API. * @{ @@ -1056,10 +1058,11 @@ function _locale_export_po($language = NULL, $output = NULL) { watchdog('locale', 'Exported translation file: %filename.', array('%filename' => $filename)); } // Download the file for the client. - header("Content-Disposition: attachment; filename=$filename"); - header("Content-Type: text/plain; charset=utf-8"); - print $output; - drupal_exit(); + $headers = array( + 'Content-Disposition' => "attachment; filename=$filename", + 'Content-Type' => 'text/plain; charset=utf-8', + ); + return new Response($output, 200, $headers); } /** diff --git a/core/includes/install.inc b/core/includes/install.inc index 1ebfb21..d0aadb6 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -1,5 +1,6 @@ 'no-cache', // Not a permanent redirect. + ); + return new RedirectResponse($base_url . '/' . $path, 302, $headers); } /** diff --git a/core/includes/xmlrpcs.inc b/core/includes/xmlrpcs.inc index 118f652..878f0e5 100644 --- a/core/includes/xmlrpcs.inc +++ b/core/includes/xmlrpcs.inc @@ -5,6 +5,9 @@ * Provides API for defining and handling XML-RPC requests. */ +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; + /** * Invokes XML-RPC methods on this server. * @@ -63,8 +66,8 @@ function xmlrpc_server($callbacks) { $data = file_get_contents('php://input'); if (!$data) { - print 'XML-RPC server accepts POST requests only.'; - drupal_exit(); + $allowed_methods = array('POST'); + throw new MethodNotAllowedHttpException($allowed_methods); } $xmlrpc_server->message = xmlrpc_message($data); if (!xmlrpc_message_parse($xmlrpc_server->message)) { @@ -123,10 +126,11 @@ function xmlrpc_server_error($error, $message = FALSE) { */ function xmlrpc_server_output($xml) { $xml = '' . "\n" . $xml; - drupal_add_http_header('Content-Length', strlen($xml)); - drupal_add_http_header('Content-Type', 'text/xml'); - echo $xml; - drupal_exit(); + $headers = array( + 'Content-Length' => strlen($xml), + 'Content-Type' => 'text/xml', + ); + return new Response($headers, $xml); } /** diff --git a/core/modules/dashboard/dashboard.module b/core/modules/dashboard/dashboard.module index 889af83..267c6b9 100644 --- a/core/modules/dashboard/dashboard.module +++ b/core/modules/dashboard/dashboard.module @@ -5,6 +5,8 @@ * Provides a dashboard page in the administrative interface. */ +use Symfony\Component\HttpFoundation\Response; + /** * Implements hook_help(). */ @@ -511,8 +513,7 @@ function dashboard_show_disabled() { } // Theme the output and end the page request. - print theme('dashboard_disabled_blocks', array('blocks' => $blocks)); - drupal_exit(); + return new Response(theme('dashboard_disabled_blocks', array('blocks' => $blocks))); } /** @@ -540,8 +541,7 @@ function dashboard_show_block_content($module, $delta) { $blocks[$module . "_" . $delta] = $block_object; $build = _block_get_renderable_region($blocks); $rendered_block = drupal_render($build); - print $rendered_block; - drupal_exit(); + return new Response($rendered_block); } /** @@ -585,7 +585,7 @@ function dashboard_update() { } drupal_set_message(t('The configuration options have been saved.'), 'status', FALSE); } - drupal_exit(); + return new Response(); } /** diff --git a/core/modules/image/image.module b/core/modules/image/image.module index 905e6a7..89a5186 100644 --- a/core/modules/image/image.module +++ b/core/modules/image/image.module @@ -8,6 +8,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Drupal\Core\File\File; /** @@ -676,7 +677,7 @@ function image_style_options($include_empty = TRUE) { function image_style_deliver($style, $scheme) { // Check that the style is defined and the scheme is valid. if (!$style || !file_stream_wrapper_valid_scheme($scheme)) { - drupal_exit(); + throw new NotFoundHttpException(); } $args = func_get_args(); @@ -714,10 +715,8 @@ function image_style_deliver($style, $scheme) { if (!$lock_acquired) { // Tell client to retry again in 3 seconds. Currently no browsers are known // to support Retry-After. - drupal_add_http_header('Status', '503 Service Unavailable'); - drupal_add_http_header('Retry-After', 3); - print t('Image generation in progress. Try again shortly.'); - drupal_exit(); + $headers = array('Retry-After' => 3); + return new Response(t('Image generation in progress. Try again shortly.'), 503, $headers); } } diff --git a/core/modules/openid/openid.inc b/core/modules/openid/openid.inc index 518dc8a..b0eb97b 100644 --- a/core/modules/openid/openid.inc +++ b/core/modules/openid/openid.inc @@ -5,6 +5,8 @@ * OpenID utility functions. */ +use Symfony\Component\HttpFoundation\RedirectResponse; + /** * Diffie-Hellman Key Exchange Default Value. * @@ -74,9 +76,7 @@ function openid_redirect_http($url, $message) { } $sep = (strpos($url, '?') === FALSE) ? '?' : '&'; - header('Location: ' . $url . $sep . implode('&', $query), TRUE, 302); - - drupal_exit(); + return new RedirectResponse($url . $sep . implode('&', $query), 302); } /** @@ -97,9 +97,8 @@ function openid_redirect($url, $message) { $output .= '' . "\n"; $output .= "\n"; $output .= "\n"; - print $output; - drupal_exit(); + return new Response($output); } function openid_redirect_form($form, &$form_state, $url, $message) { diff --git a/core/modules/overlay/overlay.module b/core/modules/overlay/overlay.module index 7fb7e0b..2271536 100644 --- a/core/modules/overlay/overlay.module +++ b/core/modules/overlay/overlay.module @@ -580,8 +580,7 @@ function overlay_page_delivery_callback_alter(&$callback) { */ function overlay_deliver_empty_page() { $empty_page = '' . drupal_get_css() . drupal_get_js() . ''; - print $empty_page; - drupal_exit(); + return new Response($empty_page); } /** diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index f34c766..dd98d75 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -2292,8 +2292,7 @@ function system_run_cron() { * Menu callback: return information about PHP. */ function system_php() { - phpinfo(); - drupal_exit(); + return phpinfo(); } /**