Commit 3d673fc4 authored by David Mudrák's avatar David Mudrák

MDL-26609 Admins are warned if they try to install or upgrade to unstable version

The commit introduces four new constants that can be used to declare a
maturity level of Moodle core and, in the future, of extension plugins.
If the administrator is about to install or upgrade Moodle to a version
that is not considered as production-ready yet, a warning is displayed
before any change in the database.
parent 48fe5c6c
......@@ -70,6 +70,8 @@ Options:
problem encountered.
--agree-license Indicates agreement with software license,
required in non-interactive mode.
--allow-unstable Install even if the version is not marked as stable yet,
required in non-interactive mode.
-h, --help Print out this help
Example:
......@@ -136,9 +138,6 @@ $CFG->early_install_lang = true;
$parts = explode('/', str_replace('\\', '/', dirname(dirname(__FILE__))));
$CFG->admin = array_pop($parts);
require($CFG->dirroot.'/version.php');
$CFG->target_release = $release;
//point pear include path to moodles lib/pear so that includes and requires will search there for files before anywhere else
//the problem is that we need specific version of quickforms and hacked excel files :-(
ini_set('include_path', $CFG->libdir.'/pear' . PATH_SEPARATOR . ini_get('include_path'));
......@@ -154,6 +153,9 @@ require_once($CFG->libdir.'/deprecatedlib.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/componentlib.class.php');
require($CFG->dirroot.'/version.php');
$CFG->target_release = $release;
//Database types
$databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'native'),
'pgsql' => moodle_database::get_driver_instance('pgsql', 'native'),
......@@ -193,6 +195,7 @@ list($options, $unrecognized) = cli_get_params(
'adminpass' => '',
'non-interactive' => false,
'agree-license' => false,
'allow-unstable' => false,
'help' => false
),
array(
......@@ -402,6 +405,27 @@ $CFG->langotherroot = $CFG->dataroot.'/lang';
$CFG->langlocalroot = $CFG->dataroot.'/lang';
get_string_manager(true);
// make sure we are installing stable release or require a confirmation
if (isset($maturity)) {
if (($maturity < MATURITY_STABLE) and !$options['allow-unstable']) {
$maturitylevel = get_string('maturity'.$maturity, 'admin');
if ($interactive) {
cli_separator();
cli_heading(get_string('notice'));
echo get_string('maturitycorewarning', 'admin', $maturitylevel) . PHP_EOL;
echo get_string('continue') . PHP_LOL;
$prompt = get_string('cliyesnoprompt', 'admin');
$input = cli_input($prompt, '', array(get_string('clianswerno', 'admin'), get_string('cliansweryes', 'admin')));
if ($input == get_string('clianswerno', 'admin')) {
exit(1);
}
} else {
cli_error(get_string('maturitycorewarning', 'admin'));
}
}
}
// ask for db type - show only drivers available
if ($interactive) {
$options['dbtype'] = strtolower($options['dbtype']);
......
......@@ -40,8 +40,16 @@ require_once($CFG->libdir.'/environmentlib.php');
// now get cli options
list($options, $unrecognized) = cli_get_params(array('non-interactive'=>false, 'help'=>false),
array('h'=>'help'));
list($options, $unrecognized) = cli_get_params(
array(
'non-interactive' => false,
'allow-unstable' => false,
'help' => false
),
array(
'h' => 'help'
)
);
$interactive = empty($options['non-interactive']);
......@@ -59,6 +67,8 @@ Site defaults may be changed via local/defaults.php.
Options:
--non-interactive No interactive questions or confirmations
--allow-unstable Upgrade even if the version is not marked as stable yet,
required in non-interactive mode.
-h, --help Print out this help
Example:
......@@ -73,7 +83,7 @@ if (empty($CFG->version)) {
cli_error(get_string('missingconfigversion', 'debug'));
}
require("$CFG->dirroot/version.php"); // defines $version and $release
require("$CFG->dirroot/version.php"); // defines $version, $release and $maturity
$CFG->target_release = $release; // used during installation and upgrades
if ($version < $CFG->version) {
......@@ -93,6 +103,22 @@ if (!check_moodle_environment($version, $environment_results, false, ENV_SELECT_
exit(1);
}
// make sure we are upgrading to a stable release or display a warning
if (isset($maturity)) {
if (($maturity < MATURITY_STABLE) and !$options['allow-unstable']) {
$maturitylevel = get_string('maturity'.$maturity, 'admin');
if ($interactive) {
cli_separator();
cli_heading(get_string('notice'));
echo get_string('maturitycorewarning', 'admin', $maturitylevel) . PHP_EOL;
cli_separator();
} else {
cli_error(get_string('maturitycorewarning', 'admin', $maturitylevel));
}
}
}
if ($interactive) {
echo html_to_text(get_string('upgradesure', 'admin', $newversion))."\n";
$prompt = get_string('cliyesnoprompt', 'admin');
......
......@@ -86,7 +86,7 @@ if (!isset($CFG->version)) {
$version = null;
$release = null;
require("$CFG->dirroot/version.php"); // defines $version and $release
require("$CFG->dirroot/version.php"); // defines $version, $release and $maturity
$CFG->target_release = $release; // used during installation and upgrades
if (!$version or !$release) {
......@@ -135,9 +135,18 @@ if (!core_tables_exist()) {
$PAGE->set_cacheable(false);
echo $OUTPUT->header();
echo $OUTPUT->heading("Moodle $release");
if (isset($maturity)) {
// main version.php declares moodle code maturity
if ($maturity < MATURITY_STABLE) {
$maturitylevel = get_string('maturity'.$maturity, 'admin');
echo $OUTPUT->box(get_string('maturitycorewarning', 'admin', $maturitylevel), 'generalbox maturitywarning');
}
}
$releasenoteslink = get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/en/Release_Notes');
$releasenoteslink = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $releasenoteslink); // extremely ugly validation hack
echo $OUTPUT->box($releasenoteslink, 'generalbox boxaligncenter boxwidthwide');
echo $OUTPUT->box($releasenoteslink, 'generalbox releasenoteslink');
require_once($CFG->libdir.'/environmentlib.php');
if (!check_moodle_environment($release, $environment_results, true, ENV_SELECT_RELEASE)) {
......@@ -194,6 +203,13 @@ if ($version > $CFG->version) { // upgrade
$PAGE->set_heading($stradministration);
$PAGE->set_cacheable(false);
echo $OUTPUT->header();
if (isset($maturity)) {
// main version.php declares moodle code maturity
if ($maturity < MATURITY_STABLE) {
$maturitylevel = get_string('maturity'.$maturity, 'admin');
echo $OUTPUT->box(get_string('maturitycorewarning', 'admin', $maturitylevel), 'generalbox maturitywarning');
}
}
$continueurl = new moodle_url('index.php', array('confirmupgrade' => 1));
$cancelurl = new moodle_url('index.php');
echo $OUTPUT->confirm(get_string('upgradesure', 'admin', $a->newversion), $continueurl, $cancelurl);
......
......@@ -680,6 +680,13 @@ $string['maintinprogress'] = 'Maintenance is in progress...';
$string['managelang'] = 'Manage';
$string['managelicenses'] = 'Manage licences';
$string['manageqtypes'] = 'Manage question types';
$string['maturity50'] = 'Alpha';
$string['maturity100'] = 'Beta';
$string['maturity150'] = 'Release candidate';
$string['maturity200'] = 'Stable version';
$string['maturitycorewarning'] = 'You are going to install or upgrade Moodle to a version marked as "{$a}"
that is not considered as production-ready yet. Please make sure this is intentional
and that you are using correct checkout of Moodle source code.';
$string['maxbytes'] = 'Maximum uploaded file size';
$string['maxconsecutiveidentchars'] = 'Consecutive identical characters';
$string['maxeditingtime'] = 'Maximum time to edit posts';
......
......@@ -53,6 +53,14 @@ define('MEMORY_EXTRA', -3);
/** Extremely large memory limit - not recommended for standard scripts */
define('MEMORY_HUGE', -4);
/**
* Software maturity levels used by the core and plugins
*/
define('MATURITY_ALPHA', 50); // internals can be tested using white box techniques
define('MATURITY_BETA', 100); // feature complete, ready for preview and testing
define('MATURITY_RC', 150); // tested, will be released unless there are fatal bugs
define('MATURITY_STABLE', 200); // ready for production deployment
/**
* Simple class. It is usually used instead of stdClass because it looks
* more familiar to Java developers ;-) Do not use for type checking of
......
......@@ -23,6 +23,9 @@
#page-admin-index .adminerror,
#page-admin-index .adminwarning {margin:20px;}
#page-admin-index .maturitywarning {margin-left:auto;margin-right:auto;text-align:center;width:60%;background-color:#ffd3d9;}
#page-admin-index .releasenoteslink {margin-left:auto;margin-right:auto;text-align:center;width:60%;}
#page-admin-enrol .enrolplugintable {width:700px;margin:1em auto;}
#page-admin-report-capability-index #settingsform h2,
......@@ -144,4 +147,4 @@ table.flexible .r1 {background-color: #FAFAFA;}
*/
#page-admin-webservice-service_users .missingcaps {color: #ff6600;font-size: 90%;}
#page-admin-setting-webservicetokens .missingcaps {color: #ff6600;font-size: 90%;}
#page-admin-webservice-service_functions .functiondesc {font-size: 90%;}
\ No newline at end of file
#page-admin-webservice-service_functions .functiondesc {font-size: 90%;}
......@@ -29,7 +29,10 @@
defined('MOODLE_INTERNAL') || die();
$version = 2011030300.00; // YYYYMMDD = date of the last version bump
// XX = daily increments
$release = '2.0.2+ (Build: 20110303)'; // Human-friendly version name
$version = 2011030300.00; // YYYYMMDD = date of the last version bump
// XX = daily increments
$release = '2.0.2+ (Build: 20110303)'; // Human-friendly version name
$maturity = MATURITY_STABLE; // this version's maturity level
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment