diff --git a/core/includes/common.inc b/core/includes/common.inc index 0b95dcd..f31b32d 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -1,5 +1,6 @@ $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 1150fce..6de4983 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/modules/image/image.module b/core/modules/image/image.module index 397ac95..dc63e2b 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; /** @@ -718,7 +719,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(); @@ -756,10 +757,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 d594dde..a4e0ef4 100644 --- a/core/modules/openid/openid.inc +++ b/core/modules/openid/openid.inc @@ -5,6 +5,9 @@ * OpenID utility functions. */ +use Symfony\Component\HttpFoundation\RedirectResponse; +use Symfony\Component\HttpFoundation\Response; + /** * Diffie-Hellman Key Exchange Default Value. * @@ -74,9 +77,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 +98,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 e57ff5f..8144771 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 dcd261c..7b754e6 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -2288,7 +2288,6 @@ function system_run_cron() { */ function system_php() { phpinfo(); - drupal_exit(); } /** diff --git a/core/modules/system/tests/modules/form_test/form_test.module b/core/modules/system/tests/modules/form_test/form_test.module index 86e810d..4135345 100644 --- a/core/modules/system/tests/modules/form_test/form_test.module +++ b/core/modules/system/tests/modules/form_test/form_test.module @@ -5,6 +5,8 @@ * Helper module for the form API tests. */ +use Symfony\Component\HttpFoundation\JsonResponse; + /** * Implements hook_menu(). */ @@ -294,10 +296,7 @@ function form_test_menu() { * Form submit handler to return form values as JSON. */ function _form_test_submit_values_json($form, &$form_state) { - // This won't have a proper JSON header, but Drupal doesn't check for that - // anyway so this is fine until it's replaced with a JsonResponse. - print drupal_json_encode($form_state['values']); - drupal_exit(); + return new JsonResponse($form_state['values']); } /** diff --git a/core/modules/xmlrpc/xmlrpc.server.inc b/core/modules/xmlrpc/xmlrpc.server.inc index e1c160b..72aec1a 100644 --- a/core/modules/xmlrpc/xmlrpc.server.inc +++ b/core/modules/xmlrpc/xmlrpc.server.inc @@ -5,6 +5,9 @@ * Page callback file for the xmlrpc module. */ +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; + /** * Process an XML-RPC request. */ @@ -71,8 +74,7 @@ function xmlrpc_server($callbacks) { $data = file_get_contents('php://input'); if (!$data) { - print 'XML-RPC server accepts POST requests only.'; - drupal_exit(); + throw new MethodNotAllowedHttpException(array('POST'), 'XML-RPC server accepts POST requests only.'); } $xmlrpc_server->message = xmlrpc_message($data); if (!xmlrpc_message_parse($xmlrpc_server->message)) { @@ -131,10 +133,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($xml, 200, $headers); } /**