diff --git a/core/includes/batch.inc b/core/includes/batch.inc index 2a51fb5..3e37841 100644 --- a/core/includes/batch.inc +++ b/core/includes/batch.inc @@ -469,7 +469,9 @@ function _batch_finished() { } // Use drupal_redirect_form() to handle the redirection logic. - drupal_redirect_form($_batch['form_state']); + if ($redirect = drupal_redirect_form($_batch['form_state'])) { + return $redirect; + } // If no redirection happened, redirect to the originating page. In case the // form needs to be rebuilt, save the final $form_state for diff --git a/core/includes/form.inc b/core/includes/form.inc index 6093965..ddaf572 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -910,7 +910,7 @@ function drupal_process_form($form_id, &$form, &$form_state) { } $batch['progressive'] = !$form_state['programmed']; - batch_process(); + return batch_process(); // Execution continues only for programmatic forms. // For 'regular' forms, we get redirected to the batch processing @@ -1275,8 +1275,7 @@ function drupal_redirect_form($form_state) { if (!isset($form_state['redirect']) || $form_state['redirect'] !== FALSE) { if (isset($form_state['redirect'])) { if (is_array($form_state['redirect'])) { - $url = call_user_func_array('url', $form_state['redirect']); - return new RedirectResponse($url, 302); + return new RedirectResponse($form_state['redirect'], 302); } else { // This function can be called from the installer, which guarantees @@ -5135,7 +5134,7 @@ function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = NU $function($batch['url'], $options); } else { - return new RedirectResponse(url($batch['url'], $options), 302); + return new RedirectResponse(array($batch['url'], $options), 302); } } else { diff --git a/core/lib/Drupal/Core/EventSubscriber/ResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ResponseSubscriber.php index dbed20a..6d72e10 100644 --- a/core/lib/Drupal/Core/EventSubscriber/ResponseSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/ResponseSubscriber.php @@ -27,7 +27,7 @@ public function onKernelResponse(FilterResponseEvent $event) { $response = $event->getResponse(); if ($response instanceOf RedirectResponse) { - $options = array('absolute' => TRUE); + $options = array(); $request = $event->getRequest(); $destination = $request->query->get('destination'); @@ -45,6 +45,12 @@ public function onKernelResponse(FilterResponseEvent $event) { $target_path = $response->getTargetUrl(); } + // @todo: Use a custom redirect response for URL's with arguments? + if (is_array($target_path)) { + list($target_path, $options) = $target_path; + } + $options['absolute'] = TRUE; + // @todo this should be replaced by the event subscriber pattern? drupal_alter('redirect_response', $target_path, $options, $status); diff --git a/core/modules/openid/openid.module b/core/modules/openid/openid.module index 4ad79fa..b7e271a 100644 --- a/core/modules/openid/openid.module +++ b/core/modules/openid/openid.module @@ -809,7 +809,7 @@ function openid_authentication($response) { // registration page and prefill with the values we received. $destination = drupal_get_destination(); unset($_GET['destination']); - return new RedirectResponse(url('user/register', array('query' => $destination))); + return new RedirectResponse(array('user/register', array('query' => $destination))); } else { drupal_set_message(t('Only site administrators can create new user accounts.'), 'error'); diff --git a/core/modules/openid/tests/openid_test.module b/core/modules/openid/tests/openid_test.module index 9aa5023..db2c284 100644 --- a/core/modules/openid/tests/openid_test.module +++ b/core/modules/openid/tests/openid_test.module @@ -311,7 +311,7 @@ function _openid_test_endpoint_authenticate() { 'openid.mode' => 'error', 'openid.error' => 'Unexpted identity', ); - return new RedirectResponse(url($_REQUEST['openid_return_to'], array('query' => $response, 'external' => TRUE))); + return new RedirectResponse(array($_REQUEST['openid_return_to'], array('query' => $response, 'external' => TRUE))); } // Generate unique identifier for this authentication. diff --git a/core/modules/overlay/overlay.module b/core/modules/overlay/overlay.module index 7159965..cc0669c 100644 --- a/core/modules/overlay/overlay.module +++ b/core/modules/overlay/overlay.module @@ -136,7 +136,7 @@ function overlay_init() { // #overlay=admin/modules to actually enable the overlay. if (isset($_SESSION['overlay_enable_redirect']) && $_SESSION['overlay_enable_redirect']) { unset($_SESSION['overlay_enable_redirect']); - return new RedirectResponse(url('', array('fragment' => 'overlay=' . $current_path))); + return new RedirectResponse(array('', array('fragment' => 'overlay=' . $current_path))); } if (isset($_GET['render']) && $_GET['render'] == 'overlay') { diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module index d7adb65..0f887a8 100644 --- a/core/modules/simpletest/simpletest.module +++ b/core/modules/simpletest/simpletest.module @@ -54,8 +54,8 @@ function simpletest_menu() { ); $items['admin/config/development/testing/results/%'] = array( 'title' => 'Test result', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('simpletest_result_form', 5), + 'page callback' => 'simpletest_test_result', + 'page arguments' => array(5), 'description' => 'View result of tests.', 'access arguments' => array('administer unit tests'), 'file' => 'simpletest.pages.inc', diff --git a/core/modules/simpletest/simpletest.pages.inc b/core/modules/simpletest/simpletest.pages.inc index 3cc6a50..3b99bc8 100644 --- a/core/modules/simpletest/simpletest.pages.inc +++ b/core/modules/simpletest/simpletest.pages.inc @@ -201,17 +201,25 @@ function simpletest_test_form_submit($form, &$form_state) { } /** - * Test results form for $test_id. + * Page callback for the rest results. + * + * @param string $test_id + * The ID of the executed test. */ -function simpletest_result_form($form, &$form_state, $test_id) { +function simpletest_test_result($test_id) { // Make sure there are test results to display and a re-run is not being performed. - $results = array(); if (is_numeric($test_id) && !$results = simpletest_result_get($test_id)) { drupal_set_message(t('No test results to display.'), 'error'); return new RedirectResponse('admin/config/development/testing'); - // @todo what to do about this? - return $form; } + return drupal_get_form('simpletest_result_form', $test_id); +} + +/** + * Test results form for $test_id. + */ +function simpletest_result_form($form, &$form_state, $test_id) { + $results = simpletest_result_get($test_id); // Load all classes and include CSS. drupal_add_css(drupal_get_path('module', 'simpletest') . '/simpletest.css'); diff --git a/core/modules/user/user.pages.inc b/core/modules/user/user.pages.inc index 16c2397..aba8dce 100644 --- a/core/modules/user/user.pages.inc +++ b/core/modules/user/user.pages.inc @@ -418,7 +418,7 @@ function user_cancel_confirm($account, $timestamp = 0, $hashed_pass = '') { function user_page() { global $user; if ($user->uid) { - return new RedirectResponse(url('user/' . $user->uid, array('absolute' => TRUE))); + return new RedirectResponse('user/' . $user->uid); } else { return drupal_get_form('user_login_form');