Really Struggling with file_rewrite_pluginfile_urls() - Moodle 3.9

Re: Really Struggling with file_rewrite_pluginfile_urls() - Moodle 3.9

by Davo Smith -
Number of replies: 0
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
The most likely explanation is a problem with your local_pluginname_pluginfile() function inside local/pluginname/lib.php - if you have xdebug installed + a suitable IDE, I suggest you put a break point in that function and step through to determine why it is not returning the file when requested by the browser (if you don't have xdebug, you may have to resort to echo/var_dump statements, but that is a lot more fiddly to do).

Edit: just reread and realised that you are serving files with component 'course', and filearea 'summary', so it will not be attempting to look for the local_pluginname_pluginfile() function - instead it will be serving the file directly from filelib.php. I suggest you search that file for the line:
if ($filearea === 'summary' || $filearea === 'overviewfiles') {
and start debugging from there.

I can guarantee, however, that a contextid of 1 will not be able to return files stored in a contextid of 27 (as shown in your screenshot). You can get the correct context from:
$context = context_course::instance($courseid);
$contextid = $context->id;

Average of ratings: Useful (1)