]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-20697 get_site() now throws exception in case of any problems (except during...
authorPetr Skoda <skodak@moodle.org>
Sun, 1 Nov 2009 09:05:59 +0000 (09:05 +0000)
committerPetr Skoda <skodak@moodle.org>
Sun, 1 Nov 2009 09:05:59 +0000 (09:05 +0000)
lib/setup.php

index ba160a65db4aa4c30ad886d6b0401c02bf743ba3..f43b4b9fac9511c3a8fcbabfe4bc5c52a239de48 100644 (file)
@@ -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!)