]> git.mjollnir.org Git - moodle.git/commitdiff
Another attempt to get redirect() to not redirect if an error was output to the scree...
authortjhunt <tjhunt>
Sun, 1 Apr 2007 22:19:39 +0000 (22:19 +0000)
committertjhunt <tjhunt>
Sun, 1 Apr 2007 22:19:39 +0000 (22:19 +0000)
lib/weblib.php

index d88dec5258d41abca396d064899105ccf51deec7..45d7d2ecb198c6f16e241aecbb136e9a7b5f1a81 100644 (file)
@@ -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;
     }