From e711e369553a9d549b0127818ea9f77b460b5283 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Mon, 1 Apr 2024 23:26:41 +0800 Subject: [PATCH] wip --- moodle/Util/MoodleUtil.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/moodle/Util/MoodleUtil.php b/moodle/Util/MoodleUtil.php index 45cb0cb..d643423 100644 --- a/moodle/Util/MoodleUtil.php +++ b/moodle/Util/MoodleUtil.php @@ -239,6 +239,7 @@ public static function getMoodleComponent(File $file, $selfPath = true): ?string $components = self::calculateAllComponents($moodleRoot); // Have been unable to load components, done. if (empty($components)) { + error_log("No components found"); return null; } } @@ -249,8 +250,11 @@ public static function getMoodleComponent(File $file, $selfPath = true): ?string if (empty($componentPath)) { continue; } + + $componentPath = str_replace('\\', '/', $componentPath . DIRECTORY_SEPARATOR); + // Look for component paths matching the file path. - if (strpos($file->path, $componentPath . DIRECTORY_SEPARATOR) === 0) { + if (strpos(MoodleUtil::getStandardisedFilename($file), $componentPath . DIRECTORY_SEPARATOR) === 0) { // First match found should be the better one always. We are done. return $component; }