From 3316fe24d5aab4d2ea0993ab99fde3b8baaf8bd1 Mon Sep 17 00:00:00 2001 From: skodak Date: Tue, 26 May 2009 17:44:25 +0000 Subject: [PATCH] MDL-15249 more cleanup and refactoring - towards cli upgrade --- admin/index.php | 22 +--------------------- lib/upgradelib.php | 24 ++++++++++++++++++++++++ lib/weblib.php | 7 ++++++- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/admin/index.php b/admin/index.php index f3f4e142fa..00e5ec9ad3 100644 --- a/admin/index.php +++ b/admin/index.php @@ -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); diff --git a/lib/upgradelib.php b/lib/upgradelib.php index 1b712abd98..c6c7b6b106 100644 --- a/lib/upgradelib.php +++ b/lib/upgradelib.php @@ -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 diff --git a/lib/weblib.php b/lib/weblib.php index f90bd16d77..d5508d10d9 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -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 = << 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; } -?> -- 2.39.5