MDL-37500 cache: integration review touchups.

Issues:
1. Fix setType calls
2. Changing from default to all and editing again, default is still selected.
3. Uncheck all options causes error.
4. Doesn't seem to be restricting based upon option.
5. Picked all and got coding error with the database thing.
6. Bad title: https://github.com/samhemelryk/moodle/commit/wip-MDL-37500-m25#L1R157
7. Amend comments - should only be removed once 2.5 is the minimum version for an upgrade.
8. Document the defaultsharing option.

Outcomes:
1. Fixed - copy paste error.
2. Fixed - mforms was applying the default value despite a value being provided. A quirk of elements with array names.
3. Fixed - validation now requires at least one option to be selected.
4. Fixed - issue rose from definitions not being re-parsed. cache/admin.php now reparses the first time a user visits the page.
5. Fixed - better purging of definitions when working with them anonymously. Unit test added.
6. Fixed - new string added and used.
7. Fixed - comments amended.

New issue to address parsing of definitions during upgrade.
New issue to add debugging notice if definition sets only one possible sharing option and that option is user input.
This commit is contained in:
Sam Hemelryk
2013-05-07 12:49:12 +12:00
parent 46e17f04c7
commit 5f5776c1e6
8 changed files with 110 additions and 14 deletions
+14 -3
View File
@@ -30,6 +30,15 @@ require_once($CFG->dirroot.'/lib/adminlib.php');
require_once($CFG->dirroot.'/cache/locallib.php');
require_once($CFG->dirroot.'/cache/forms.php');
// The first time the user visits this page we are going to reparse the definitions.
// Just ensures that everything is up to date.
// We flag is session so that this only happens once as people are likely to hit
// this page several times if making changes.
if (empty($SESSION->cacheadminreparsedefinitions)) {
cache_helper::update_definitions();
$SESSION->cacheadminreparsedefinitions = true;
}
$action = optional_param('action', null, PARAM_ALPHA);
admin_externalpage_setup('cacheconfig');
@@ -155,9 +164,10 @@ if (!empty($action) && confirm_sesskey()) {
if (!array_key_exists($definition, $definitions)) {
throw new cache_exception('Invalid cache definition requested');
}
$title = get_string('editdefinitionmappings', 'cache', $definition);
$title = get_string('editdefinitionsharing', 'cache', $definition);
$sharingoptions = $definitions[$definition]['sharingoptions'];
$mform = new cache_definition_sharing_form($PAGE->url, array('definition' => $definition, 'sharingoptions' => $sharingoptions));
$customdata = array('definition' => $definition, 'sharingoptions' => $sharingoptions);
$mform = new cache_definition_sharing_form($PAGE->url, $customdata);
$mform->set_data(array(
'sharing' => $definitions[$definition]['selectedsharingoption'],
'userinputsharingkey' => $definitions[$definition]['userinputsharingkey']
@@ -167,7 +177,8 @@ if (!empty($action) && confirm_sesskey()) {
} else if ($data = $mform->get_data()) {
$component = $definitions[$definition]['component'];
$area = $definitions[$definition]['area'];
cache_helper::purge_by_definition($component, $area);
// Purge the stores removing stale data before we alter the sharing option.
cache_helper::purge_stores_used_by_definition($component, $area);
$writer = cache_config_writer::instance();
$sharing = array_sum(array_keys($data->sharing));
$userinputsharingkey = $data->userinputsharingkey;