From 20482f9d41ac20bcc9dd9be31cfcadf4bb6ed688 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Mon, 25 Jun 2018 15:05:33 +0100 Subject: [PATCH 1/2] MDL-62792 filter_mathjaxloader: don't use statics for once-only items --- filter/mathjaxloader/filter.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/filter/mathjaxloader/filter.php b/filter/mathjaxloader/filter.php index a6010bfbcad..50e568e45d2 100644 --- a/filter/mathjaxloader/filter.php +++ b/filter/mathjaxloader/filter.php @@ -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; } } From 9f38628abc23e76f06a76f9f8e44655545c65669 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Mon, 25 Jun 2018 15:16:23 +0100 Subject: [PATCH 2/2] MDL-62792 filters: fix some bad PHPdocs --- lib/filterlib.php | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/lib/filterlib.php b/lib/filterlib.php index 0a9753ba4f6..693922cd25f 100644 --- a/lib/filterlib.php +++ b/lib/filterlib.php @@ -302,15 +302,36 @@ class filter_manager { * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class null_filter_manager { + /** + * As for the equivalent {@link filter_manager} method. + * + * @param string $text The text to filter + * @param context $context not used. + * @param array $options not used + * @param array $skipfilters not used + * @return string resulting text. + */ public function filter_text($text, $context, array $options = array(), array $skipfilters = null) { return $text; } + /** + * As for the equivalent {@link filter_manager} method. + * + * @param string $string The text to filter + * @param context $context not used. + * @return string resulting string + */ public function filter_string($string, $context) { return $string; } + /** + * As for the equivalent {@link filter_manager} method. + * + * @deprecated Since Moodle 3.0 MDL-50491. + */ public function text_filtering_hash() { throw new coding_exception('filter_manager::text_filtering_hash() can not be used any more'); } @@ -429,9 +450,9 @@ abstract class moodle_text_filter { /** * Override this function to actually implement the filtering. * - * @param $text some HTML content. + * @param string $text some HTML content to process. * @param array $options options passed to the filters - * @return the HTML content after the filtering has been applied. + * @return string the HTML content after the filtering has been applied. */ public abstract function filter($text, array $options = array()); } @@ -520,8 +541,6 @@ function filter_get_name($filter) { * sorted in alphabetical order of name. */ function filter_get_all_installed() { - global $CFG; - $filternames = array(); foreach (core_component::get_plugin_list('filter') as $filter => $fulldir) { if (is_readable("$fulldir/filter.php")) { @@ -1428,9 +1447,10 @@ function filter_phrases($text, &$link_array, $ignoretagsopen=NULL, $ignoretagscl } /** - * @todo Document this function - * @param array $linkarray - * @return array + * Remove duplicate from a list of {@link filterobject}. + * + * @param filterobject[] $linkarray a list of filterobject. + * @return filterobject[] the same list, but with dupicates removed. */ function filter_remove_duplicates($linkarray) {