mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-61766 xmldb: Handle custom admin path
This commit is contained in:
parent
39fab18e27
commit
a2e7a47a6e
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user