-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
4.2, 4.2.1, 4.2.2
-
None
-
MOODLE_402_STABLE
On my moodle installation, I wasn't able to access files on a nextcloud repository.
Versions:
Moodle Version: 4.2.2+ (Build: 20230902)
Nextcloud Version: 25.0.8 (run from a custom docker cluster)
Detailed error description:
Moodle and our nextcloud-instance were set up correctly, authentication was working, but not files displayed in the repository.
I contacted our service provider who set up our nextcloud instance, this is what they came up with:
Our Nextcloud sends out Dav-Responses with only lower case header fields. E.g. instead of sending ["Content-Type"] it sends ["content-type"].
Since moodle evaluates the response case sensitiv, the fields are ignored and no files shown. Using an other nextloud instance (aio), that doesn't send out all lower case fields, there is no issue with moodle.
As far as I know, the behaviour of our moodle instance is valid, even if maybe unusual. As such a solution needs to change moodle code.
Reproducibility:
Set up a nexcloud repository as described on https://docs.moodle.org/402/de/Nextcloud_Repository with a nextcloud instance, that sends out Dav-Responses header with all lower case field names. This might be difficult, but maybe not necesarry, since the responsible code is already identified (see suggested quick fix).
Suggested quick fix:
Following quick fix suggested by our nextcloud provider works:
In <moodle-directory>/lib/webdavlib.php below line 845
if (strcmp($response['status']['status-code'],'207') == 0 ) { |
add:
// Add new key to array, if header is send in lower-case
|
if (array_key_exists("content-type", $response['header'])) { |
$response['header']['Content-Type'] = $response['header']['content-type']; } |
This is a work-around only for the field 'Content-Type'. I'm sure there is a better solution, that fixes the problem in general.
I hope I described the issue well enough and someone who knows the code better than me can come up with a good solution.