Skip to content

Commit

Permalink
Merge branch 'MDL-26609-version-maturity' of git://github.com/mudrd8m…
Browse files Browse the repository at this point in the history
…z/moodle
  • Loading branch information
stronk7 committed Mar 7, 2011
2 parents 29c8520 + 1a4d6a5 commit 5f9f071
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 18 deletions.
31 changes: 28 additions & 3 deletions admin/cli/install.php
Expand Up @@ -70,6 +70,8 @@
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:
Expand Down Expand Up @@ -136,9 +138,6 @@
$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'));
Expand All @@ -154,6 +153,9 @@
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'),
Expand Down Expand Up @@ -193,6 +195,7 @@
'adminpass' => '',
'non-interactive' => false,
'agree-license' => false,
'allow-unstable' => false,
'help' => false
),
array(
Expand Down Expand Up @@ -402,6 +405,28 @@
$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('morehelp') . ': ' . get_docs_url('admin/versions') . 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']);
Expand Down
41 changes: 38 additions & 3 deletions admin/cli/upgrade.php
Expand Up @@ -40,8 +40,16 @@


// 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']);

Expand All @@ -59,6 +67,8 @@
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:
Expand All @@ -73,13 +83,14 @@
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) {
cli_error(get_string('downgradedcore', 'error'));
}

$oldversion = "$CFG->release ($CFG->version)";
$newversion = "$release ($version)";

// test environment first
Expand All @@ -93,6 +104,30 @@
exit(1);
}

if ($interactive) {
$a = new stdClass();
$a->oldversion = $oldversion;
$a->newversion = $newversion;
echo cli_heading(get_string('databasechecking', '', $a)) . PHP_EOL;
}

// 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;
echo get_string('morehelp') . ': ' . get_docs_url('admin/versions') . 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');
Expand Down
35 changes: 28 additions & 7 deletions admin/index.php
Expand Up @@ -86,7 +86,7 @@

$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) {
Expand Down Expand Up @@ -130,14 +130,26 @@
if (empty($confirmrelease)) {
$strcurrentrelease = get_string('currentrelease');
$PAGE->navbar->add($strcurrentrelease);
$PAGE->set_title($strinstallation.' - Moodle '.$CFG->target_release);
$PAGE->set_heading($strinstallation);
$PAGE->set_title($strinstallation);
$PAGE->set_heading($strinstallation . ' - Moodle ' . $CFG->target_release);
$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(
$OUTPUT->container(get_string('maturitycorewarning', 'admin', $maturitylevel)) .
$OUTPUT->container($OUTPUT->doc_link('admin/versions', get_string('morehelp'))),
'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)) {
Expand Down Expand Up @@ -189,11 +201,20 @@
$strdatabasechecking = get_string('databasechecking', '', $a);

if (empty($confirmupgrade)) {
$PAGE->navbar->add($strdatabasechecking);
$PAGE->set_title($strdatabasechecking);
$PAGE->set_heading($stradministration);
$PAGE->set_title($stradministration);
$PAGE->set_heading($strdatabasechecking);
$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(
$OUTPUT->container(get_string('maturitycorewarning', 'admin', $maturitylevel)) .
$OUTPUT->container($OUTPUT->doc_link('admin/versions', get_string('morehelp'))),
'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);
Expand Down
7 changes: 7 additions & 0 deletions lang/en/admin.php
Expand Up @@ -680,6 +680,13 @@
$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';
Expand Down
2 changes: 1 addition & 1 deletion lang/en/moodle.php
Expand Up @@ -386,7 +386,7 @@
$string['currentpicture'] = 'Current picture';
$string['currentrelease'] = 'Current release information';
$string['currentversion'] = 'Current version';
$string['databasechecking'] = 'Upgrading Moodle database from version {$a->oldversion} to {$a->newversion}...';
$string['databasechecking'] = 'Upgrading Moodle database from version {$a->oldversion} to {$a->newversion}';
$string['databaseperformance'] = 'Database performance';
$string['databasesetup'] = 'Setting up database';
$string['databasesuccess'] = 'Database was successfully upgraded';
Expand Down
8 changes: 8 additions & 0 deletions lib/setuplib.php
Expand Up @@ -53,6 +53,14 @@
/** 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
Expand Down
5 changes: 4 additions & 1 deletion theme/standard/style/admin.css
Expand Up @@ -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,
Expand Down Expand Up @@ -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%;}
#page-admin-webservice-service_functions .functiondesc {font-size: 90%;}
9 changes: 6 additions & 3 deletions version.php
Expand Up @@ -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

0 comments on commit 5f9f071

Please sign in to comment.