MDL-69779 core: Improved the X-Redirect-By header when debugging is on
This commit is contained in:
@@ -52,6 +52,7 @@ information provided here is intended especially for developers.
|
||||
renamed to `is_listed()` and `get_not_listed()` respectively.
|
||||
* Method `mustache_helper_collection::strip_blacklisted_helpers()` has been deprecated and renamed to
|
||||
`strip_disallowed_helpers()`.
|
||||
* Function redirect() now emits a line of backtrace into the X-Redirect-By header when debugging is one
|
||||
|
||||
=== 3.9 ===
|
||||
* Following function has been deprecated, please use \core\task\manager::run_from_cli().
|
||||
|
||||
+10
-2
@@ -2954,9 +2954,17 @@ function redirect($url, $message='', $delay=null, $messagetype = \core\output\no
|
||||
\core\session\manager::write_close();
|
||||
|
||||
if ($delay == 0 && !$debugdisableredirect && !headers_sent()) {
|
||||
|
||||
// This helps when debugging redirect issues like loops and it is not clear
|
||||
// which layer in the stack sent the redirect header.
|
||||
@header('X-Redirect-By: Moodle');
|
||||
// which layer in the stack sent the redirect header. If debugging is on
|
||||
// then the file and line is also shown.
|
||||
$redirectby = 'Moodle';
|
||||
if (debugging('', DEBUG_DEVELOPER)) {
|
||||
$origin = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0];
|
||||
$redirectby .= ' /' . str_replace($CFG->dirroot . '/', '', $origin['file']) . ':' . $origin['line'];
|
||||
}
|
||||
@header("X-Redirect-By: $redirectby");
|
||||
|
||||
// 302 might not work for POST requests, 303 is ignored by obsolete clients.
|
||||
@header($_SERVER['SERVER_PROTOCOL'] . ' 303 See Other');
|
||||
@header('Location: '.$url);
|
||||
|
||||
Reference in New Issue
Block a user