MDL-15249 more cleanup and refactoring - towards cli upgrade

This commit is contained in:
skodak 2009-05-26 17:44:25 +00:00
parent 1e308b644e
commit 3316fe24d5
3 changed files with 31 additions and 22 deletions

View 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);

View 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;
}
}

View 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;
}
?>