Tuesday, October 2, 2012

Guest role cannot access folder content....

One of my customers reported that one of her courses that allows guest access, with an enrollment key, was erroring when trying to access a folder in the course.

This is the error:

Fatal error: Call to a member function get_url() on a non-object in C:\wamp\www\training\mod\folder\renderer.php on line 70 Call Stack: 0.0009 714128 1. {main}() C:\wamp\www\training\mod\folder\view.php:0 0.7120 49524856 2. mod_folder_renderer->folder_tree() C:\wamp\www\training\mod\folder\view.php:76 0.7146 49549032 3. plugin_renderer_base->render() C:\wamp\www\training\mod\folder\renderer.php:38 0.7147 49549120 4. mod_folder_renderer->render_folder_tree() C:\wamp\www\training\lib\outputrenderers.php:215 0.7147 49550000 5. mod_folder_renderer->htmllize_tree() C:\wamp\www\training\mod\folder\renderer.php:45 0.7154 49551072 6. mod_folder_renderer->htmllize_tree() C:\wamp\www\training\mod\folder\renderer.php:65

After spending about an hr messing with the role permissions and trying a backup and restore workaround, I punted and went to try to find any information around this error.  I tried a couple combinations of search strings like "moodle access folder problem guest role" or "guest role cannot access folder in course" and probably a couple other combinations, but only got moodle doc pages in my result set.

Eventually, I tried something like "folder/view error guest access" and found a tracker issue!  That was a good sign.  This is the link to the tracker issue. I search for the tracker issue # in the latest release of moodle 2.3.2 (which I do not yet have installed).  But sadly did not find it in the 2.3.2 release notes.

BUT, I did find a comment in the tracker issue where someone posted a workaround until the bug fix was released.  This is the update to a core file that solved the problem.  Thanks so much to Sebastian Michel

While waiting for a definitive patch from the core developers, here is a quick fix (at your own risks!). In lib/filebrowser/file_info_context_module.php in get_file_info function
replace:
if (!is_viewing($this->context) and !is_enrolled($this->context)) {

with:
if (!is_viewing($this->context) and !is_enrolled($this->context) and !is_guest($this->context)) {



No comments:

Post a Comment