From cc50d6664f771fd155ae1a1012cde21b2bb13e2c Mon Sep 17 00:00:00 2001 From: skodak Date: Sun, 14 May 2006 17:23:29 +0000 Subject: [PATCH] I hope final fix for warnings when using error() after print_header() with buffering on, solution was to flush all buffers and reenable SID rewrite when needed; merged from MOODLE_16_STABLE --- lib/cookieless.php | 4 ++-- lib/weblib.php | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/cookieless.php b/lib/cookieless.php index c4f8766a5f4..dc3209393af 100644 --- a/lib/cookieless.php +++ b/lib/cookieless.php @@ -1,4 +1,4 @@ -usesid=true; * in config.php. @@ -116,7 +116,7 @@ function sid_start_ob(){ } } } - ini_set("session.use_trans_sid", "true"); // try and turn on trans_sid + @ini_set("session.use_trans_sid", "true"); // try and turn on trans_sid if (ini_get("session.use_trans_sid")!=0 ){ // use trans sid as its available ini_set("url_rewriter.tags", "a=href,area=href,script=src,link=href," diff --git a/lib/weblib.php b/lib/weblib.php index efb1141b251..11bef1a194d 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -4029,6 +4029,12 @@ function print_scale_menu_helpbutton($courseid, $scale) { function error ($message, $link='') { global $CFG, $SESSION; + // flush all buffers so that we know if headers were already sent + while (@ob_end_flush()); + // reenable SID rewrite if needed + if (!empty($CFG->usesid) and empty($_COOKIE['MoodleSession'.$CFG->sessioncookie])) { + sid_start_ob(); + } if (!headers_sent()) { //header not yet printed @header('HTTP/1.0 404 Not Found');