Details
-
Type:
Sub-task
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.8.2
-
Fix Version/s: 2.0
-
Component/s: Installation
-
Labels:None
-
Affected Branches:MOODLE_18_STABLE
-
Fixed Branches:MOODLE_20_STABLE
Description
The installer script doesn't tolerate symlinks when checking if $CFG->dirroot is valid.
Lets say Moodle folder is on a separate volume, but symlinked in the DocumentRoot:
/var/www/html/moodle -> /mnt/moodle/moodle_1.8.2
Apache is set with DocumentRoot to /var/www/html/, and Moodle with $CFG->dirroot to /var/www/html/.
In this instance, the following check during install will fail (/admin/index.php, line 79):
$dirroot = dirname(realpath("../index.php"));
if (!empty($dirroot) and $dirroot != $CFG->dirroot) {
realpath() will retrieve the "real path" to the index.php, in this case /mnt/moodle/moodle_1.8.2, and comparison with
/var/www/html will fail.
I recommend a minor change to the code:
$dirroot = dirname(realpath("../index.php"));
$cfg_dirroot = dirname(realpath($CFG->dirroot . "/index.php"));
if (!empty($dirroot) and $dirroot != $cfg_dirroot) {
This will expand both paths to their physical paths, and compare /mnt/moodle/moodle_1.8.2==/mnt/moodle/moodle_1.8.2
Well, if the mountain won't come to Muhammad...
Workaround is to use the realpath() in config.php (based on the example above):
$CFG->dirroot = realpath('/var/www/html/moodle');