Skip to content

Commit

Permalink
MDL-50491 filters: Eliminate un-resettable static caching.
Browse files Browse the repository at this point in the history
This was breaking unit tests. I think it is no longer necessary since
get_config now has good caching of its own.
  • Loading branch information
timhunt committed Jun 17, 2015
1 parent 7d94679 commit 41e5e52
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 50 deletions.
30 changes: 1 addition & 29 deletions filter/emoticon/filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@

class filter_emoticon extends moodle_text_filter {

/**
* @var array global configuration for this filter
*
* This might be eventually moved into parent class if we found it
* useful for other filters, too.
*/
protected static $globalconfig;

/**
* Apply the filter to the text
*
Expand Down Expand Up @@ -77,27 +69,7 @@ public function filter($text, array $options = array()) {
* @return string|object|null
*/
protected function get_global_config($name=null) {
$this->load_global_config();
if (is_null($name)) {
return self::$globalconfig;

} elseif (array_key_exists($name, self::$globalconfig)) {
return self::$globalconfig->{$name};

} else {
return null;
}
}

/**
* Makes sure that the global config is loaded in $this->globalconfig
*
* @return void
*/
protected function load_global_config() {
if (is_null(self::$globalconfig)) {
self::$globalconfig = get_config(get_class($this));
}
return get_config(get_class($this), $name);
}

/**
Expand Down
22 changes: 1 addition & 21 deletions filter/urltolink/filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,7 @@ public function filter($text, array $options = array()) {
* @return string|object|null
*/
protected function get_global_config($name=null) {
$this->load_global_config();
if (is_null($name)) {
return self::$globalconfig;

} elseif (array_key_exists($name, self::$globalconfig)) {
return self::$globalconfig->{$name};

} else {
return null;
}
}

/**
* Makes sure that the global config is loaded in $this->globalconfig
*
* @return void
*/
protected function load_global_config() {
if (is_null(self::$globalconfig)) {
self::$globalconfig = get_config('filter_urltolink');
}
return get_config('filter_urltolink', $name);
}

/**
Expand Down

0 comments on commit 41e5e52

Please sign in to comment.