MDL-61766 xmldb: Handle custom admin path

This commit is contained in:
Jun Pataleta 2018-03-27 17:12:00 +08:00
parent 39fab18e27
commit a2e7a47a6e

View File

@ -234,7 +234,14 @@ class xmldb_structure extends xmldb_object {
// Normalize paths to compare them.
$filepath = realpath($this->name); // File path comes in name.
$filename = basename($filepath);
$structurepath = realpath($CFG->dirroot . DIRECTORY_SEPARATOR . $this->path . DIRECTORY_SEPARATOR . $filename);
$normalisedpath = $this->path;
if ($CFG->admin !== 'admin') {
$needle = 'admin/';
if (strpos($this->path, $needle) === 0) {
$normalisedpath = substr_replace($this->path, "$CFG->admin/", 0, strlen($needle));
}
}
$structurepath = realpath($CFG->dirroot . DIRECTORY_SEPARATOR . $normalisedpath . DIRECTORY_SEPARATOR . $filename);
if ($filepath !== $structurepath) {
$relativepath = dirname(str_replace(realpath($CFG->dirroot) . DIRECTORY_SEPARATOR, '', $filepath));
$this->errormsg = 'PATH attribute does not match file directory: ' . $relativepath;