mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-68440 cache: Added counting of default mappings
This commit is contained in:
parent
46f977a8bf
commit
3d49421a21
20
cache/classes/administration_helper.php
vendored
20
cache/classes/administration_helper.php
vendored
@ -101,13 +101,31 @@ abstract class administration_helper extends cache_helper {
|
||||
ksort($default);
|
||||
$return = $return + $default;
|
||||
|
||||
foreach ($instance->get_definition_mappings() as $mapping) {
|
||||
$mappings = $instance->get_definition_mappings();
|
||||
foreach ($mappings as $mapping) {
|
||||
if (!array_key_exists($mapping['store'], $return)) {
|
||||
continue;
|
||||
}
|
||||
$return[$mapping['store']]['mappings']++;
|
||||
}
|
||||
|
||||
// Now get all definitions, and if not mapped, increment the defaults for the mode.
|
||||
$modemappings = $instance->get_mode_mappings();
|
||||
foreach ($instance->get_definitions() as $definition) {
|
||||
// Construct the definition name to search for.
|
||||
$defname = $definition['component'] . '/' . $definition['area'];
|
||||
// Skip if definition is already mapped.
|
||||
if (array_search($defname, array_column($mappings, 'definition')) !== false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$mode = $definition['mode'];
|
||||
// Get the store name of the default mapping from the mode.
|
||||
$index = array_search($mode, array_column($modemappings, 'mode'));
|
||||
$store = $modemappings[$index]['store'];
|
||||
$return[$store]['mappings']++;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
7
cache/tests/administration_helper_test.php
vendored
7
cache/tests/administration_helper_test.php
vendored
@ -92,7 +92,12 @@ class core_cache_administration_helper_testcase extends advanced_testcase {
|
||||
$this->assertEquals(0, $summary['default']);
|
||||
$this->assertEquals(1, $summary['isready']);
|
||||
$this->assertEquals(1, $summary['requirementsmet']);
|
||||
$this->assertEquals(1, $summary['mappings']);
|
||||
|
||||
// Find the number of mappings to sessionstore.
|
||||
$mappingcount = count(array_filter($config->get_definitions(), function($element) {
|
||||
return $element['mode'] === cache_store::MODE_APPLICATION;
|
||||
}));
|
||||
$this->assertEquals($mappingcount, $summary['mappings']);
|
||||
|
||||
$definitionsummaries = core_cache\administration_helper::get_definition_summaries();
|
||||
$this->assertInternalType('array', $definitionsummaries);
|
||||
|
Loading…
x
Reference in New Issue
Block a user