From 7b51fb61d263b6a5f1d48ef7fcbf9686d8a1e003 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Sun, 1 Nov 2009 09:05:59 +0000 Subject: [PATCH] MDL-20697 get_site() now throws exception in case of any problems (except during installation) - the problem is we can not recover from this automatically --- lib/setup.php | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/setup.php b/lib/setup.php index ba160a65db..f43b4b9fac 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -324,25 +324,26 @@ if (function_exists('register_shutdown_function')) { // Defining the site try { $SITE = get_site(); -} catch (dml_read_exception $e) { - $SITE = null; -} - -if ($SITE) { /** * If $SITE global from {@link get_site()} is set then SITEID to $SITE->id, otherwise set to 1. */ define('SITEID', $SITE->id); - // And the 'default' course - $COURSE = clone($SITE); // For now. This will usually get reset later in require_login() etc. -} else { - /** - * @ignore - */ - define('SITEID', 1); - // And the 'default' course - $COURSE = new object; // no site created yet - $COURSE->id = 1; + // And the 'default' course - this will usually get reset later in require_login() etc. + $COURSE = clone($SITE); +} catch (dml_read_exception $e) { + $SITE = null; + if (empty($CFG->version)) { + // we are just installing + /** + * @ignore + */ + define('SITEID', 1); + // And the 'default' course + $COURSE = new object(); // no site created yet + $COURSE->id = 1; + } else { + throw $e; + } } // define SYSCONTEXTID in config.php if you want to save some queries (after install or upgrade!) -- 2.39.5