mirror of
https://github.com/moodle/moodle.git
synced 2025-04-25 10:26:17 +02:00
Another attempt to get redirect() to not redirect if an error was output to the screen, to make dubuggin easier. Sorry I had not noticed the bit in the docs that says error_get_last was PHP 5.2.0+.
This commit is contained in:
parent
b107549c32
commit
b388c7664d
@ -4977,6 +4977,19 @@ function notice_yesno ($message, $linkyes, $linkno, $optionsyes=NULL, $optionsno
|
||||
print_box_end();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide an definition of error_get_last for PHP before 5.2.0. This simply
|
||||
* returns NULL, since there is not way to get the right answer.
|
||||
*/
|
||||
if (!version_compare(phpversion(), '5.2.0') >= 0) {
|
||||
// the eval is needed to prevent PHP 5.2+ from getting a parse error!
|
||||
eval('
|
||||
function error_get_last() {
|
||||
return NULL;
|
||||
}
|
||||
');
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirects the user to another page, after printing a notice
|
||||
*
|
||||
@ -5008,9 +5021,10 @@ function redirect($url, $message='', $delay=-1, $adminroot = '') {
|
||||
$surl = addslashes($url);
|
||||
|
||||
/// At developer debug level. Don't redirect if errors have been printed on screen.
|
||||
$errorprinted = false;
|
||||
if (debugging('', DEBUG_DEVELOPER) && $CFG->debugdisplay && false /* && error_get_last()*/) {
|
||||
$errorprinted = true;
|
||||
/// Currenly only works in PHP 5.2+
|
||||
$error = error_get_last();
|
||||
$errorprinted = debugging('', DEBUG_DEVELOPER) && $CFG->debugdisplay && !empty($error);
|
||||
if ($errorprinted) {
|
||||
$message = "<strong>Error output, so disabling automatic redirect.</strong></p><p>" . $message;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user