Commit fb38dd95 authored by Ruslan Kabalin's avatar Ruslan Kabalin
Browse files

Remove wwwroot from the database (bug #780177)



wwwroot will be autogenerated on every page load if it is not set in the config
file. There are some implications of storing it in the database, it particular
it affects the hostname and protocol changes. Since its autogeneration takes
just 2ms there is no much sense keeping it in the database.

Change-Id: I7c08539c6ad4e4c5fba819a459b7f60bb1d9741e
Signed-off-by: default avatarRuslan Kabalin <ruslan.kabalin@luns.net.uk>
parent fbc45f73
......@@ -157,8 +157,7 @@ catch (SQLException $e) {
db_ignore_sql_exceptions(false);
}
// Make sure wwwroot is set and available, either in the database or in the
// config file. Cron requires it for some purposes.
// Make sure wwwroot is set. If it is not defined in the config, then determine it.
if (!isset($CFG->wwwroot) && isset($_SERVER['HTTP_HOST'])) {
$proto = (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') ? 'https://' : 'http://';
$host = (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST'];
......@@ -176,15 +175,9 @@ if (!isset($CFG->wwwroot) && isset($_SERVER['HTTP_HOST'])) {
} else {
$path = '/';
}
$wwwroot = $proto . $host . $path;
try {
set_config('wwwroot', $wwwroot);
}
catch (Exception $e) {
// Just set it directly. The system will most likely not be installed, so we don't care
$CFG->wwwroot = $wwwroot;
}
$CFG->wwwroot = $proto . $host . $path;
}
if (isset($CFG->wwwroot)) {
if (substr($CFG->wwwroot, -1, 1) != '/') {
$CFG->wwwroot .= '/';
......
......@@ -2269,5 +2269,10 @@ function xmldb_core_upgrade($oldversion=0) {
change_field_precision($table, $field);
}
if ($oldversion < 2011051300) {
// We do not store wwwroot in the database any more
delete_records('config','field','wwwroot');
}
return $status;
}
......@@ -28,7 +28,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2011050600;
$config->version = 2011051300;
$config->release = '1.4.0alpha2dev';
$config->minupgradefrom = 2008040200;
$config->minupgraderelease = '1.0.0 (release tag 1.0.0_RELEASE)';
......
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