From aa893d6b767bb7d674db0f70f010c2b66b1df46c Mon Sep 17 00:00:00 2001 From: skodak Date: Sun, 10 Sep 2006 21:10:48 +0000 Subject: [PATCH] fixed several bogus errors and warnings during installation and upgrades, forced logout when upgrading from 1.6 --- admin/index.php | 20 ++++++++++++++++++++ lib/setup.php | 33 ++++++++++++++++++++++++++++----- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/admin/index.php b/admin/index.php index 1b1f8c6d6c..153742bbaa 100644 --- a/admin/index.php +++ b/admin/index.php @@ -109,6 +109,10 @@ $linktoscrolltoerrors = ''; if (! $maintables) { + /// hide errors from headers in case debug enabled in config.php + $origdebug = $CFG->debug; + $CFG->debug = 5; + error_reporting($CFG->debug); if (empty($agreelicence)) { $strlicense = get_string("license"); print_header($strlicense, $strlicense, $strlicense, "", "", false, " ", " "); @@ -127,6 +131,9 @@ $strdatabasesuccess = get_string("databasesuccess"); print_header($strdatabasesetup, $strdatabasesetup, $strdatabasesetup, "", $linktoscrolltoerrors, false, " ", " "); + /// return to original debugging level + $CFG->debug = $origdebug; + error_reporting($CFG->debug); upgrade_log_start(); $db->debug = true; @@ -204,6 +211,16 @@ $a->newversion = "$release ($version)"; $strdatabasechecking = get_string("databasechecking", "", $a); + // hide errors from headers in case debug is enabled + $origdebug = $CFG->debug; + $CFG->debug = 5; + error_reporting($CFG->debug); + + // logout in case we are upgrading from pre 1.7 version - prevention of weird session problems + if ($CFG->version < 2006050600) { + require_logout(); + } + if (empty($confirmupgrade)) { print_header($strdatabasechecking, $stradministration, $strdatabasechecking, "", "", false, " ", " "); @@ -214,6 +231,9 @@ $strdatabasesuccess = get_string("databasesuccess"); print_header($strdatabasechecking, $stradministration, $strdatabasechecking, "", $linktoscrolltoerrors, false, " ", " "); + /// return to original debugging level + $CFG->debug = $origdebug; + error_reporting($CFG->debug); upgrade_log_start(); print_heading($strdatabasechecking); $db->debug=true; diff --git a/lib/setup.php b/lib/setup.php index f5dbea1eec..49758f8c1d 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -192,6 +192,14 @@ global $HTTPSPAGEREQUIRED; raise_memory_limit('64M'); // We should never NEED this much but just in case... +/// Disable errors for now - needed for installation when debug enabled in config.php + if (isset($CFG->debug)) { + $originalconfigdebug = $CFG->debug; + unset($CFG->debug); + } else { + $originalconfigdebug = -1; + } + /// If $CFG->unicodedb is not set, get it from database or calculate it because we need /// to know it to "set names" properly. /// (this is the only database interaction before "set names") @@ -220,12 +228,13 @@ global $HTTPSPAGEREQUIRED; $db->LogSQL(); } - -/// Set error reporting back to normal - if (!isset($CFG->debug)) { // empty() would override 0 or false from config.php - $CFG->debug = 5; +/// Prevent warnings from roles when upgrading with debug on + if (isset($CFG->debug)) { + $originaldatabasedebug = $CFG->debug; + unset($CFG->debug); + } else { + $originaldatabasedebug = -1; } - error_reporting($CFG->debug); //// Defining the site @@ -247,6 +256,20 @@ global $HTTPSPAGEREQUIRED; } +/// Set error reporting back to normal + if ($originaldatabasedebug == -1) { + $CFG->debug = 5; + } else { + $CFG->debug = $originaldatabasedebug; + } + if ($originalconfigdebug !== -1) { + $CFG->debug = $originalconfigdebug; + } + unset($originalconfigdebug); + unset($originaldatabasedebug); + error_reporting($CFG->debug); + + /// Set a default enrolment configuration (see bug 1598) if (!isset($CFG->enrol)) { $CFG->enrol = 'manual'; -- 2.39.5