Skip to content

Commit

Permalink
MDL-28134 General : added branch variable to version.php for reliable…
Browse files Browse the repository at this point in the history
… docs versioned links.
  • Loading branch information
Aparup Banerjee committed May 3, 2012
1 parent aa753ac commit ed01233
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
3 changes: 2 additions & 1 deletion admin/cli/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
cli_error(get_string('missingconfigversion', 'debug'));
}

require("$CFG->dirroot/version.php"); // defines $version, $release and $maturity
require("$CFG->dirroot/version.php"); // defines $version, $release, $branch and $maturity
$CFG->target_release = $release; // used during installation and upgrades

if ($version < $CFG->version) {
Expand Down Expand Up @@ -150,6 +150,7 @@
upgrade_core($version, true);
}
set_config('release', $release);
set_config('branch', $branch);

// unconditionally upgrade
upgrade_noncore(true);
Expand Down
7 changes: 6 additions & 1 deletion admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@

$version = null;
$release = null;
require("$CFG->dirroot/version.php"); // defines $version, $release and $maturity
$branch = null;
require("$CFG->dirroot/version.php"); // defines $version, $release, $branch and $maturity
$CFG->target_release = $release; // used during installation and upgrades

if (!$version or !$release) {
Expand Down Expand Up @@ -260,6 +261,10 @@
set_config('release', $release);
}

if ($branch <> $CFG->branch) { // Update the branch
set_config('branch', $branch);
}

if (moodle_needs_upgrading()) {
if (!$PAGE->headerprinted) {
// means core upgrade or installation was not already done
Expand Down
1 change: 1 addition & 0 deletions lib/installlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ function install_cli_database(array $options, $interactive) {
// install core
install_core($version, true);
set_config('release', $release);
set_config('branch', $branch);

// install all plugins types, local, etc.
upgrade_noncore(true);
Expand Down
15 changes: 6 additions & 9 deletions lib/setuplib.php
Original file line number Diff line number Diff line change
Expand Up @@ -566,19 +566,16 @@ function get_exception_info($ex) {
*/
function get_docs_url($path=null) {
global $CFG;
// Check that $CFG->release has been set up, during installation it won't be.
if (empty($CFG->release)) {
// Check that $CFG->branch has been set up, during installation it won't be.
if (empty($CFG->branch)) {
// It's not there yet so look at version.php
include($CFG->dirroot.'/version.php');
} else {
// We can use $CFG->release and avoid having to include version.php
$release = $CFG->release;
// We can use $CFG->branch and avoid having to include version.php
$branch = $CFG->branch;
}
// Attempt to match the branch from the release
if (preg_match('/^(.)\.(.)/', $release, $matches)) {
// We should ALWAYS get here
$branch = $matches[1].$matches[2];
} else {
// ensure branch is valid.
if (!$branch) {
// We should never get here but in case we do lets set $branch to .
// the smart one's will know that this is the current directory
// and the smarter ones will know that there is some smart matching
Expand Down
1 change: 1 addition & 0 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@

$release = '2.3dev (Build: 20120427)'; // Human-friendly version name

$branch = '23'; // this version's branch
$maturity = MATURITY_ALPHA; // this version's maturity level

0 comments on commit ed01233

Please sign in to comment.