Commit 5266d1b4 authored by Francois Marier's avatar Francois Marier
Browse files

Revert "Remove wwwroot from the database (bug #780177)"

This reverts commit fb38dd95

.

It turns out that we do need the wwwroot to be in the database
because the code that sends forum posts via email runs in php
cli mode and is needs to get the hostname of the site to embed
in the headers.

While not specifically mentioned in bug #794490, it was spitting
out warnings in the logs.

Conflicts:

	htdocs/lib/db/upgrade.php
	htdocs/lib/version.php

Change-Id: I36b33ac72eee01f71056a45c706f2fc8674620ec
Signed-off-by: default avatarFrancois Marier <francois@catalyst.net.nz>
parent c5bff875
......@@ -157,7 +157,8 @@ catch (SQLException $e) {
db_ignore_sql_exceptions(false);
}
// Make sure wwwroot is set. If it is not defined in the config, then determine it.
// Make sure wwwroot is set and available, either in the database or in the
// config file. Cron requires it when sending out forums emails.
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'];
......@@ -195,9 +196,15 @@ if (!isset($CFG->wwwroot) && isset($_SERVER['HTTP_HOST'])) {
} else {
$path = '/';
}
$CFG->wwwroot = $proto . $host . $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;
}
}
if (isset($CFG->wwwroot)) {
if (substr($CFG->wwwroot, -1, 1) != '/') {
$CFG->wwwroot .= '/';
......
......@@ -2271,11 +2271,6 @@ 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');
}
if ($oldversion < 2011051700) {
// Create new "external" category
insert_record('blocktype_category', (object) array('name' => 'external'));
......
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