mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 08:55:15 +02:00
MDL-42664 Fix the filter_manager instantiation
For legacy reasons, the $CFG->perfdebug uses values 7 for disabled and 15 for enabled. Because of this typo, Moodle has always created instance of the slower performance_measuring_filter_manager instead of the standard filter_manager, regardless the perfdebug setting.
This commit is contained in:
parent
5386f0bbfe
commit
c928c60718
@ -81,7 +81,7 @@ class filter_manager {
|
||||
public static function instance() {
|
||||
global $CFG;
|
||||
if (is_null(self::$singletoninstance)) {
|
||||
if (!empty($CFG->perfdebug)) {
|
||||
if (!empty($CFG->perfdebug) and $CFG->perfdebug > 7) {
|
||||
self::$singletoninstance = new performance_measuring_filter_manager();
|
||||
} else {
|
||||
self::$singletoninstance = new self();
|
||||
|
@ -660,4 +660,19 @@ class core_filterlib_testcase extends advanced_testcase {
|
||||
$this->assertEquals('emailprotect,multilang', $CFG->stringfilters);
|
||||
$this->assertEquals(1, $CFG->filterall);
|
||||
}
|
||||
|
||||
public function test_filter_manager_instance() {
|
||||
|
||||
set_config('perfdebug', 7);
|
||||
filter_manager::reset_caches();
|
||||
$filterman = filter_manager::instance();
|
||||
$this->assertInstanceOf('filter_manager', $filterman);
|
||||
$this->assertNotInstanceOf('performance_measuring_filter_manager', $filterman);
|
||||
|
||||
set_config('perfdebug', 15);
|
||||
filter_manager::reset_caches();
|
||||
$filterman = filter_manager::instance();
|
||||
$this->assertInstanceOf('filter_manager', $filterman);
|
||||
$this->assertInstanceOf('performance_measuring_filter_manager', $filterman);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user