MDL-29474 fix regressions in CLI install

This commit is contained in:
Petr Skoda 2011-10-27 12:47:05 +02:00
parent 7b27861217
commit f433088d5a
3 changed files with 40 additions and 17 deletions

View File

@ -20,7 +20,6 @@
*
* This script is not intended for beginners!
* Potential problems:
* - environment check is not present yet
* - su to apache account or sudo before execution
* - not compatible with Windows platform
*
@ -91,7 +90,11 @@ if (file_exists($configfile)) {
echo "\n\n";
}
cli_error(get_string('clialreadyinstalled', 'install'));
if ($DB->get_manager()->table_exists('config')) {
cli_error(get_string('clialreadyinstalled', 'install'));
} else {
cli_error(get_string('clialreadyconfigured', 'install'));
}
}
$olddir = getcwd();
@ -636,7 +639,21 @@ if (!file_exists($configfile)) {
cli_error('Can not create config file.');
}
// remember selected language
$installlang = $CFG->lang;
// return back to original dir before executing setup.php which changes the dir again
chdir($olddir);
// We have config.php, it is a real php script from now on :-)
require($configfile);
// use selected language
$CFG->lang = $installlang;
$SESSION->lang = $CFG->lang;
require("$CFG->dirroot/version.php");
// Test environment first.
require_once($CFG->libdir . '/environmentlib.php');
list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
if (!$envstatus) {
$errors = environment_get_errors($environment_results);
@ -649,21 +666,11 @@ if (!$envstatus) {
}
// Test plugin dependencies.
require_once($CFG->libdir . '/pluginlib.php');
if (!plugin_manager::instance()->all_plugins_ok($version)) {
cli_error(get_string('pluginschecktodo', 'admin'));
}
// remember selected language
$installlang = $CFG->lang;
// return back to original dir before executing setup.php which changes the dir again
chdir($olddir);
// We have config.php, it is a real php script from now on :-)
require($configfile);
// use selected language
$CFG->lang = $installlang;
$SESSION->lang = $CFG->lang;
install_cli_database($options, $interactive);
echo get_string('cliinstallfinished', 'install')."\n";

View File

@ -42,7 +42,8 @@ $string['availablelangs'] = 'List of available languages';
$string['caution'] = 'Caution';
$string['cliadminpassword'] = 'New admin user password';
$string['cliadminusername'] = 'Admin account username';
$string['clialreadyinstalled'] = 'File config.php already exists, please use admin/cli/upgrade.php if you want to upgrade your site.';
$string['clialreadyconfigured'] = 'File config.php already exists, please use admin/cli/install_database.php if you want to install this site.';
$string['clialreadyinstalled'] = 'File config.php already exists, please use admin/cli/upgrade.php if you want to upgrade this site.';
$string['cliinstallfinished'] = 'Installation completed successfully.';
$string['cliinstallheader'] = 'Moodle {$a} command line installation program';
$string['climustagreelicense'] = 'In non interactive mode you must agree to license by specifying --agree-license option';

View File

@ -851,7 +851,12 @@ abstract class plugintype_base {
static $pluginversions = null;
if (is_null($pluginversions) or $disablecache) {
$pluginversions = $DB->get_records_menu('config_plugins', array('name' => 'version'), 'plugin', 'plugin,value');
try {
$pluginversions = $DB->get_records_menu('config_plugins', array('name' => 'version'), 'plugin', 'plugin,value');
} catch (dml_exception $e) {
// before install
$pluginversions = array();
}
}
if (!array_key_exists($plugin, $pluginversions)) {
@ -989,7 +994,12 @@ class plugintype_block extends plugintype_base implements plugin_information {
static $blocksinfocache = null;
if (is_null($blocksinfocache) or $disablecache) {
$blocksinfocache = $DB->get_records('block', null, 'name', 'name,id,version,visible');
try {
$blocksinfocache = $DB->get_records('block', null, 'name', 'name,id,version,visible');
} catch (dml_exception $e) {
// before install
$blocksinfocache = array();
}
}
return $blocksinfocache;
@ -1318,7 +1328,12 @@ class plugintype_mod extends plugintype_base implements plugin_information {
static $modulesinfocache = null;
if (is_null($modulesinfocache) or $disablecache) {
$modulesinfocache = $DB->get_records('modules', null, 'name', 'name,id,version,visible');
try {
$modulesinfocache = $DB->get_records('modules', null, 'name', 'name,id,version,visible');
} catch (dml_exception $e) {
// before install
$modulesinfocache = array();
}
}
return $modulesinfocache;