]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-15249 more cleanup and refactoring - towards cli upgrade
authorskodak <skodak>
Tue, 26 May 2009 17:44:25 +0000 (17:44 +0000)
committerskodak <skodak>
Tue, 26 May 2009 17:44:25 +0000 (17:44 +0000)
admin/index.php
lib/upgradelib.php
lib/weblib.php

index f3f4e142fac2df942965d8cc5d1345068226f480..00e5ec9ad387491c93b43d72cc7c50e65da7d2f4 100644 (file)
@@ -99,28 +99,11 @@ if (!$version or !$release) {
     print_error('withoutversion', 'debug'); // without version, stop
 }
 
-// Check if the main tables have been installed yet or not.
-if (!$tables = $DB->get_tables() ) {    // No tables yet at all.
-    $maintables = false;
-
-} else {                                 // Check for missing main tables
-    $maintables = true;
-    $mtables = array('config', 'course', 'groupings'); // some tables used in 1.9 and 2.0, preferable something from the start and end of install.xml
-    foreach ($mtables as $mtable) {
-        if (!in_array($mtable, $tables)) {
-            $maintables = false;
-            break;
-        }
-    }
-    unset($mtables);
-}
-unset($tables);
-
 // Turn off xmlstrictheaders during upgrade.
 $origxmlstrictheaders = !empty($CFG->xmlstrictheaders);
 $CFG->xmlstrictheaders = false;
 
-if (!$maintables) {
+if (!core_tables_exist()) {
     // hide errors from headers in case debug enabled in config.php
 
     // fake some settings
@@ -193,9 +176,6 @@ if (empty($CFG->version)) {
 }
 
 if ($version > $CFG->version) {  // upgrade
-    require_once($CFG->libdir.'/db/upgrade.php');    // Defines upgrades
-    require_once($CFG->libdir.'/db/upgradelib.php'); // Core Upgrade-related functions
-
     $a->oldversion = "$CFG->release ($CFG->version)";
     $a->newversion = "$release ($version)";
     $strdatabasechecking = get_string('databasechecking', '', $a);
index 1b712abd98f5bd68f7669dfbf97dd414116e77fb..c6c7b6b106bc8a9921dd96e31c04a5c0506dfae8 100644 (file)
@@ -1106,6 +1106,9 @@ function install_core($version, $verbose) {
 function upgrade_core($version, $verbose) {
     global $CFG;
 
+    require_once($CFG->libdir.'/db/upgrade.php');    // Defines upgrades
+    require_once($CFG->libdir.'/db/upgradelib.php'); // Core Upgrade-related functions
+
     try {
         // Upgrade current language pack if we can
         if (empty($CFG->skiplangupgrade)) {
@@ -1189,3 +1192,24 @@ function upgrade_noncore($verbose) {
         upgrade_handle_exception($ex);
     }
 }
+
+/**
+ * Checks if the main tables have been installed yet or not.
+ * @return bool
+ */
+function core_tables_exist() {
+    global $DB;
+
+    if (!$tables = $DB->get_tables() ) {    // No tables yet at all.
+        return false;
+    
+    } else {                                 // Check for missing main tables
+        $mtables = array('config', 'course', 'groupings'); // some tables used in 1.9 and 2.0, preferable something from the start and end of install.xml
+        foreach ($mtables as $mtable) {
+            if (!in_array($mtable, $tables)) {
+                return false;
+            }
+        }
+        return true;
+    }        
+}
\ No newline at end of file
index f90bd16d77108ff77f0d4968a6db1c346f4e3795..d5508d10d9550aad2a4c47f3ce22249a2f29fbac 100644 (file)
@@ -7541,6 +7541,9 @@ class progress_bar {
             flush();
             $this->lastcall->pt = 0;
             $this->lastcall->time = microtime(true);
+            if (CLI_SCRIPT) {
+                return; // temporary solution for cli scripts
+            }
             $htmlcode = <<<EOT
             <script type="text/javascript">
             Number.prototype.fixed=function(n){
@@ -7606,6 +7609,9 @@ EOT;
         $this->lastcall->time = microtime(true);
         $this->lastcall->pt   = $percent;
         $w = $this->percent * $this->width;
+        if (CLI_SCRIPT) {
+            return; // temporary solution for cli scripts
+        }
         if ($es === null){
             $es = "Infinity";
         }
@@ -7827,4 +7833,3 @@ function auth_get_plugin_title ($authtype) {
     return $authtitle;
 }
 
-?>