diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/ajax.inc | 4 | ||||
-rw-r--r-- | includes/common.inc | 34 | ||||
-rw-r--r-- | includes/file.inc | 2 | ||||
-rw-r--r-- | includes/install.inc | 2 | ||||
-rw-r--r-- | includes/xmlrpcs.inc | 2 |
5 files changed, 28 insertions, 16 deletions
diff --git a/includes/ajax.inc b/includes/ajax.inc index 1b8564d7a..ca198d6fa 100644 --- a/includes/ajax.inc +++ b/includes/ajax.inc @@ -162,7 +162,7 @@ function ajax_render($commands = array(), $header = TRUE) { else { print drupal_json_encode($commands); } - exit; + drupal_exit(); } /** @@ -207,7 +207,7 @@ function ajax_get_form() { // This is likely a hacking attempt as it never happens under normal // circumstances, so we just do nothing. watchdog('ajax', 'Invalid form POST data.', array(), WATCHDOG_WARNING); - exit; + drupal_exit(); } // Since some of the submit handlers are run, redirects need to be disabled. diff --git a/includes/common.inc b/includes/common.inc index 8993047c6..e715010f2 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -656,22 +656,12 @@ function drupal_goto($path = '', array $query = array(), $fragment = NULL, $http $url = url($path, array('query' => $query, 'fragment' => $fragment, 'absolute' => TRUE)); - // Allow modules to react to the end of the page request before redirecting. - // We do not want this while running update.php. - if (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update') { - module_invoke_all('exit', $url); - } - - // Commit the session, if necessary. We need all session data written to the - // database before redirecting. - drupal_session_commit(); - header('Location: ' . $url, TRUE, $http_response_code); // The "Location" header sends a redirect status code to the HTTP daemon. In // some cases this can be wrong, so we make sure none of the code below the // drupal_goto() call gets executed upon redirection. - exit(); + drupal_exit($url); } /** @@ -2628,6 +2618,28 @@ function drupal_page_footer() { } /** + * Perform end-of-request tasks. + * + * In some cases page requests need to end without calling drupal_page_footer(). + * In these cases, call drupal_exit() instead. There should rarely be a reason + * to call exit instead of drupal_exit(); + * + * @param $destination + * If this function is called from drupal_goto(), then this argument + * will be a fully-qualified URL that is the destination of the redirect. + * This should be passed along to hook_exit() implementations. + */ +function drupal_exit($destination = NULL) { + if (drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL) { + if (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update') { + module_invoke_all('exit', $destination); + } + drupal_session_commit(); + } + exit; +} + +/** * Form an associative array from a linear array. * * This function walks through the provided array and constructs an associative diff --git a/includes/file.inc b/includes/file.inc index dc9d8236e..719d04677 100644 --- a/includes/file.inc +++ b/includes/file.inc @@ -1527,7 +1527,7 @@ function file_transfer($uri, $headers) { else { drupal_not_found(); } - exit(); + drupal_exit(); } /** diff --git a/includes/install.inc b/includes/install.inc index 69e49c951..d05a8096f 100644 --- a/includes/install.inc +++ b/includes/install.inc @@ -925,7 +925,7 @@ function install_goto($path) { global $base_url; header('Location: ' . $base_url . '/' . $path); header('Cache-Control: no-cache'); // Not a permanent redirect. - exit(); + drupal_exit(); } /** diff --git a/includes/xmlrpcs.inc b/includes/xmlrpcs.inc index cf378f4fc..35a18161d 100644 --- a/includes/xmlrpcs.inc +++ b/includes/xmlrpcs.inc @@ -109,7 +109,7 @@ function xmlrpc_server_output($xml) { drupal_add_http_header('Content-Length', strlen($xml)); drupal_add_http_header('Content-Type', 'text/xml'); echo $xml; - exit; + drupal_exit(); } /** |