MDL-62792 filter_mathjaxloader: don't use statics for once-only items
authorTim Hunt <T.J.Hunt@open.ac.uk>
Mon, 25 Jun 2018 14:05:33 +0000 (15:05 +0100)
committerTim Hunt <T.J.Hunt@open.ac.uk>
Mon, 25 Jun 2018 14:05:33 +0000 (15:05 +0100)
filter/mathjaxloader/filter.php

index a6010bf..50e568e 100644 (file)
@@ -79,10 +79,8 @@ class filter_mathjaxloader extends moodle_text_filter {
      * @param context $context The current context.
      */
     public function setup($page, $context) {
-        // This only requires execution once per request.
-        static $jsinitialised = false;
 
-        if (empty($jsinitialised)) {
+        if ($page->requires->should_create_one_time_item_now('filter_mathjaxloader-scripts')) {
             $url = get_config('filter_mathjaxloader', 'httpsurl');
             $lang = $this->map_language_code(current_language());
             $url = new moodle_url($url, array('delayStartupUntil' => 'configured'));
@@ -102,8 +100,6 @@ class filter_mathjaxloader extends moodle_text_filter {
             $params = array('mathjaxconfig' => $config, 'lang' => $lang);
 
             $page->requires->yui_module('moodle-filter_mathjaxloader-loader', 'M.filter_mathjaxloader.configure', array($params));
-
-            $jsinitialised = true;
         }
     }