-
Bug
-
Resolution: Fixed
-
Minor
-
3.5.11, 3.6.9, 3.7.5, 3.8.2, 3.9
-
MOODLE_35_STABLE, MOODLE_36_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE
-
MOODLE_37_STABLE, MOODLE_38_STABLE
-
When plugins using localcache directory to store a file for attchment, $CFG->dataroot is unconditionally added to the path with email_to_user() in lib/moodlelib.php by which the path becoming non-existent one.
Possible case is some plugin creating temporary directory with 'make_request_directory()' which creates directory in localcache which means the path inclued $CFG->dataroot.
'email_to_user()' function in lib/moodlelib.php only checks if $attachmentpath inclues $CFG->temppath and does not consider the situation which includes $CFG->dataroot.
I will add a patch which safely checks $attachmentpath already inclueds $CFG-dataroot and if so, does not add $CFG-dataroot.
Added 2nd May 2020
During the process of making a patch, experts adviced me to add more allowed paths, so I added them.
Testing instructions
Use testemailattachment.php and set like this in the code.
$user->email = "<your_email_address>";
Copy the file in the moodle directory.
Change directory into the moodle directory.
Execute command,
$ php testemailattachement.php
File will not be attached with email recieved with the original code.
File will be attached with email recieved with the patched code.
- has been marked as being related by
-
MDL-70130 email_to_user() no longer can attach files from request directory
- Closed