Moodle

Support for symlinked Moodle folder

Details

  • Type: Sub-task Sub-task
  • Status: Closed Closed
  • Priority: Minor 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

Issue Links

Activity

Hide
Slobodan Jovcic added a comment -

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

Show
Slobodan Jovcic added a comment - 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');
Hide
Petr Škoda (skodak) added a comment -

hi, I added something like this into new 2.0 installer - thanks a lot for the idea!

Show
Petr Škoda (skodak) added a comment - hi, I added something like this into new 2.0 installer - thanks a lot for the idea!
Hide
Mark van Hoek added a comment -

This is the same as MDL-6513

Show
Mark van Hoek added a comment - This is the same as MDL-6513

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: