abgreeve / moodle-block_stash

Engage your students! Gamify your courses by hiding objects for your students to find.
5 stars 13 forks source link

Avoid missing context #22

Closed sh-csg closed 1 year ago

sh-csg commented 1 year ago

If you use the stash shortcodes in a block (e.g. block_html) and you have

then you get

Call to a member function get_course_context() on null

making it impossible to access the page again. This does not affect course modules (e.g. mod_label). Thanks to @fdagner for discovering this!

The problem occurrs as $this->env is set to null in https://github.com/branchup/moodle-filter_shortcodes/blob/dfde0e7a1bfbc2148b1827060b05530c6d480ccb/classes/local/processor/standard_processor.php#L101 and can be avoided by using $PAGE->context if $this->env->context is not available.

sh-csg commented 1 year ago

Problem seems to be similar to #6 , but I assume that my code keeps more functionality.

abgreeve commented 1 year ago

Thank you for the patch. I've merged it into the master branch. This will be included in the next minor release, which should be soon.