mirror of
https://github.com/moodle/moodle.git
synced 2025-04-16 14:02:32 +02:00
MDL-25290 cache: renaming to better separate store plugins from lock plugins
This commit is contained in:
parent
42f2c59eb8
commit
26ce56fddf
14
cache/admin.php
vendored
14
cache/admin.php
vendored
@ -35,8 +35,8 @@ $action = optional_param('action', null, PARAM_ALPHA);
|
||||
admin_externalpage_setup('cacheconfig');
|
||||
$context = context_system::instance();
|
||||
|
||||
$stores = cache_administration_helper::get_store_summaries();
|
||||
$plugins = cache_administration_helper::get_plugin_summaries();
|
||||
$stores = cache_administration_helper::get_store_instance_summaries();
|
||||
$plugins = cache_administration_helper::get_store_plugin_summaries();
|
||||
$definitions = cache_administration_helper::get_definition_summaries();
|
||||
$defaultmodestores = cache_administration_helper::get_default_mode_stores();
|
||||
$locks = cache_administration_helper::get_lock_summaries();
|
||||
@ -67,7 +67,7 @@ if (!empty($action) && confirm_sesskey()) {
|
||||
$config['lock'] = $data->lock;
|
||||
}
|
||||
}
|
||||
$writer->add_plugin_instance($data->name, $data->plugin, $config);
|
||||
$writer->add_store_instance($data->name, $data->plugin, $config);
|
||||
redirect($PAGE->url, get_string('addstoresuccess', 'cache', $plugins[$plugin]['name']), 5);
|
||||
}
|
||||
break;
|
||||
@ -87,7 +87,7 @@ if (!empty($action) && confirm_sesskey()) {
|
||||
$config['lock'] = $data->lock;
|
||||
}
|
||||
}
|
||||
$writer->edit_plugin_instance($data->name, $data->plugin, $config);
|
||||
$writer->edit_store_instance($data->name, $data->plugin, $config);
|
||||
redirect($PAGE->url, get_string('editstoresuccess', 'cache', $plugins[$plugin]['name']), 5);
|
||||
}
|
||||
break;
|
||||
@ -120,7 +120,7 @@ if (!empty($action) && confirm_sesskey()) {
|
||||
exit;
|
||||
} else {
|
||||
$writer = cache_config_writer::instance();
|
||||
$writer->delete_store($store);
|
||||
$writer->delete_store_instance($store);
|
||||
redirect($PAGE->url, get_string('deletestoresuccess', 'cache'), 5);
|
||||
}
|
||||
}
|
||||
@ -186,8 +186,8 @@ if (!is_null($notification)) {
|
||||
if ($mform instanceof moodleform) {
|
||||
$mform->display();
|
||||
} else {
|
||||
echo $renderer->plugin_summaries($plugins);
|
||||
echo $renderer->store_summariers($stores, $plugins);
|
||||
echo $renderer->store_plugin_summaries($plugins);
|
||||
echo $renderer->store_instance_summariers($stores, $plugins);
|
||||
echo $renderer->definition_summaries($definitions, cache_administration_helper::get_definition_actions($context));
|
||||
echo $renderer->lock_summaries($locks);
|
||||
|
||||
|
2
cache/forms.php
vendored
2
cache/forms.php
vendored
@ -93,7 +93,7 @@ class cachestore_addinstance_form extends moodleform {
|
||||
if (!preg_match('#^[a-zA-Z0-9\-_ ]+$#', $data['name'])) {
|
||||
$errors['name'] = get_string('storenameinvalid', 'cache');
|
||||
} else if (empty($this->_customdata['store'])) {
|
||||
$stores = cache_administration_helper::get_store_summaries();
|
||||
$stores = cache_administration_helper::get_store_instance_summaries();
|
||||
if (array_key_exists($data['name'], $stores)) {
|
||||
$errors['name'] = get_string('storenamealreadyused', 'cache');
|
||||
}
|
||||
|
20
cache/locallib.php
vendored
20
cache/locallib.php
vendored
@ -118,7 +118,7 @@ class cache_config_writer extends cache_config {
|
||||
* @return bool
|
||||
* @throws cache_exception
|
||||
*/
|
||||
public function add_plugin_instance($name, $plugin, array $configuration = array()) {
|
||||
public function add_store_instance($name, $plugin, array $configuration = array()) {
|
||||
if (array_key_exists($name, $this->configstores)) {
|
||||
throw new cache_exception('Duplicate name specificed for cache plugin instance. You must provide a unique name.');
|
||||
}
|
||||
@ -219,7 +219,7 @@ class cache_config_writer extends cache_config {
|
||||
* @return bool
|
||||
* @throws cache_exception
|
||||
*/
|
||||
public function edit_plugin_instance($name, $plugin, $configuration) {
|
||||
public function edit_store_instance($name, $plugin, $configuration) {
|
||||
if (!array_key_exists($name, $this->configstores)) {
|
||||
throw new cache_exception('The requested instance does not exist.');
|
||||
}
|
||||
@ -265,7 +265,7 @@ class cache_config_writer extends cache_config {
|
||||
* @return bool
|
||||
* @throws cache_exception
|
||||
*/
|
||||
public function delete_store($name) {
|
||||
public function delete_store_instance($name) {
|
||||
if (!array_key_exists($name, $this->configstores)) {
|
||||
throw new cache_exception('The requested store does not exist.');
|
||||
}
|
||||
@ -488,7 +488,7 @@ abstract class cache_administration_helper extends cache_helper {
|
||||
* Returns an array containing all of the information about stores a renderer needs.
|
||||
* @return array
|
||||
*/
|
||||
public static function get_store_summaries() {
|
||||
public static function get_store_instance_summaries() {
|
||||
$return = array();
|
||||
$default = array();
|
||||
$instance = cache_config::instance();
|
||||
@ -544,7 +544,7 @@ abstract class cache_administration_helper extends cache_helper {
|
||||
* Returns an array of information about plugins, everything a renderer needs.
|
||||
* @return array
|
||||
*/
|
||||
public static function get_plugin_summaries() {
|
||||
public static function get_store_plugin_summaries() {
|
||||
$return = array();
|
||||
$plugins = get_plugin_list_with_file('cachestore', 'lib.php', true);
|
||||
foreach ($plugins as $plugin => $path) {
|
||||
@ -669,7 +669,7 @@ abstract class cache_administration_helper extends cache_helper {
|
||||
* @param array $storedetails
|
||||
* @return array
|
||||
*/
|
||||
public static function get_store_actions($name, array $storedetails) {
|
||||
public static function get_store_instance_actions($name, array $storedetails) {
|
||||
$actions = array();
|
||||
if (has_capability('moodle/site:config', get_system_context())) {
|
||||
$baseurl = new moodle_url('/cache/admin.php', array('store' => $name, 'sesskey' => sesskey()));
|
||||
@ -699,7 +699,7 @@ abstract class cache_administration_helper extends cache_helper {
|
||||
* @param array $plugindetails
|
||||
* @return array
|
||||
*/
|
||||
public static function get_plugin_actions($name, array $plugindetails) {
|
||||
public static function get_store_plugin_actions($name, array $plugindetails) {
|
||||
$actions = array();
|
||||
if (has_capability('moodle/site:config', get_system_context())) {
|
||||
if (!empty($plugindetails['canaddinstance'])) {
|
||||
@ -738,7 +738,7 @@ abstract class cache_administration_helper extends cache_helper {
|
||||
}
|
||||
}
|
||||
|
||||
$locks = self::get_possible_locks_for_plugin($plugindir, $plugin);
|
||||
$locks = self::get_possible_locks_for_stores($plugindir, $plugin);
|
||||
|
||||
$url = new moodle_url('/cache/admin.php', array('action' => 'addstore'));
|
||||
return new $class($url, array('plugin' => $plugin, 'store' => null, 'locks' => $locks));
|
||||
@ -776,7 +776,7 @@ abstract class cache_administration_helper extends cache_helper {
|
||||
}
|
||||
}
|
||||
|
||||
$locks = self::get_possible_locks_for_plugin($plugindir, $plugin);
|
||||
$locks = self::get_possible_locks_for_stores($plugindir, $plugin);
|
||||
|
||||
$url = new moodle_url('/cache/admin.php', array('action' => 'editstore'));
|
||||
return new $class($url, array('plugin' => $plugin, 'store' => $store, 'locks' => $locks));
|
||||
@ -789,7 +789,7 @@ abstract class cache_administration_helper extends cache_helper {
|
||||
* @param string $plugin
|
||||
* @return array|false
|
||||
*/
|
||||
protected static function get_possible_locks_for_plugin($plugindir, $plugin) {
|
||||
protected static function get_possible_locks_for_stores($plugindir, $plugin) {
|
||||
global $CFG; // Needed for includes.
|
||||
$supportsnativelocking = false;
|
||||
if (file_exists($plugindir.'/lib.php')) {
|
||||
|
8
cache/renderer.php
vendored
8
cache/renderer.php
vendored
@ -44,7 +44,7 @@ class core_cache_renderer extends plugin_renderer_base {
|
||||
* @param array $plugins
|
||||
* @return string HTML
|
||||
*/
|
||||
public function store_summariers(array $stores, array $plugins) {
|
||||
public function store_instance_summariers(array $stores, array $plugins) {
|
||||
$table = new html_table();
|
||||
$table->head = array(
|
||||
get_string('storename', 'cache'),
|
||||
@ -69,7 +69,7 @@ class core_cache_renderer extends plugin_renderer_base {
|
||||
$defaultstoreactions = get_string('defaultstoreactions', 'cache');
|
||||
|
||||
foreach ($stores as $name => $store) {
|
||||
$actions = cache_administration_helper::get_store_actions($name, $store);
|
||||
$actions = cache_administration_helper::get_store_instance_actions($name, $store);
|
||||
$modes = array();
|
||||
foreach ($store['modes'] as $mode => $enabled) {
|
||||
if ($enabled) {
|
||||
@ -127,7 +127,7 @@ class core_cache_renderer extends plugin_renderer_base {
|
||||
* @param array $plugins
|
||||
* @return string HTML
|
||||
*/
|
||||
public function plugin_summaries(array $plugins) {
|
||||
public function store_plugin_summaries(array $plugins) {
|
||||
$table = new html_table();
|
||||
$table->head = array(
|
||||
get_string('plugin', 'cache'),
|
||||
@ -148,7 +148,7 @@ class core_cache_renderer extends plugin_renderer_base {
|
||||
$table->data = array();
|
||||
|
||||
foreach ($plugins as $name => $plugin) {
|
||||
$actions = cache_administration_helper::get_plugin_actions($name, $plugin);
|
||||
$actions = cache_administration_helper::get_store_plugin_actions($name, $plugin);
|
||||
|
||||
$modes = array();
|
||||
foreach ($plugin['modes'] as $mode => $enabled) {
|
||||
|
32
cache/tests/locallib_test.php
vendored
32
cache/tests/locallib_test.php
vendored
@ -165,26 +165,26 @@ class cache_config_writer_phpunit_tests extends advanced_testcase {
|
||||
$this->assertArrayNotHasKey('addplugintest', $config->get_all_stores());
|
||||
$this->assertArrayNotHasKey('addplugintestwlock', $config->get_all_stores());
|
||||
// Add a default file instance.
|
||||
$config->add_plugin_instance('addplugintest', 'file');
|
||||
$config->add_store_instance('addplugintest', 'file');
|
||||
|
||||
cache_factory::reset();
|
||||
$config = cache_config_writer::instance();
|
||||
$this->assertArrayHasKey('addplugintest', $config->get_all_stores());
|
||||
|
||||
// Add a store with a lock described.
|
||||
$config->add_plugin_instance('addplugintestwlock', 'file', array('lock' => 'default_file_lock'));
|
||||
$config->add_store_instance('addplugintestwlock', 'file', array('lock' => 'default_file_lock'));
|
||||
$this->assertArrayHasKey('addplugintestwlock', $config->get_all_stores());
|
||||
|
||||
$config->delete_store('addplugintest');
|
||||
$config->delete_store_instance('addplugintest');
|
||||
$this->assertArrayNotHasKey('addplugintest', $config->get_all_stores());
|
||||
$this->assertArrayHasKey('addplugintestwlock', $config->get_all_stores());
|
||||
|
||||
$config->delete_store('addplugintestwlock');
|
||||
$config->delete_store_instance('addplugintestwlock');
|
||||
$this->assertArrayNotHasKey('addplugintest', $config->get_all_stores());
|
||||
$this->assertArrayNotHasKey('addplugintestwlock', $config->get_all_stores());
|
||||
|
||||
// Add a default file instance.
|
||||
$config->add_plugin_instance('storeconfigtest', 'file', array('test' => 'a', 'one' => 'two'));
|
||||
$config->add_store_instance('storeconfigtest', 'file', array('test' => 'a', 'one' => 'two'));
|
||||
$stores = $config->get_all_stores();
|
||||
$this->assertArrayHasKey('storeconfigtest', $stores);
|
||||
$this->assertArrayHasKey('configuration', $stores['storeconfigtest']);
|
||||
@ -193,7 +193,7 @@ class cache_config_writer_phpunit_tests extends advanced_testcase {
|
||||
$this->assertEquals('a', $stores['storeconfigtest']['configuration']['test']);
|
||||
$this->assertEquals('two', $stores['storeconfigtest']['configuration']['one']);
|
||||
|
||||
$config->edit_plugin_instance('storeconfigtest', 'file', array('test' => 'b', 'one' => 'three'));
|
||||
$config->edit_store_instance('storeconfigtest', 'file', array('test' => 'b', 'one' => 'three'));
|
||||
$stores = $config->get_all_stores();
|
||||
$this->assertArrayHasKey('storeconfigtest', $stores);
|
||||
$this->assertArrayHasKey('configuration', $stores['storeconfigtest']);
|
||||
@ -202,17 +202,17 @@ class cache_config_writer_phpunit_tests extends advanced_testcase {
|
||||
$this->assertEquals('b', $stores['storeconfigtest']['configuration']['test']);
|
||||
$this->assertEquals('three', $stores['storeconfigtest']['configuration']['one']);
|
||||
|
||||
$config->delete_store('storeconfigtest');
|
||||
$config->delete_store_instance('storeconfigtest');
|
||||
|
||||
try {
|
||||
$config->delete_store('default_application');
|
||||
$config->delete_store_instance('default_application');
|
||||
$this->fail('Default store deleted. This should not be possible!');
|
||||
} catch (Exception $e) {
|
||||
$this->assertInstanceOf('cache_exception', $e);
|
||||
}
|
||||
|
||||
try {
|
||||
$config->delete_store('some_crazy_store');
|
||||
$config->delete_store_instance('some_crazy_store');
|
||||
$this->fail('You should not be able to delete a store that does not exist.');
|
||||
} catch (Exception $e) {
|
||||
$this->assertInstanceOf('cache_exception', $e);
|
||||
@ -220,7 +220,7 @@ class cache_config_writer_phpunit_tests extends advanced_testcase {
|
||||
|
||||
try {
|
||||
// Try with a plugin that does not exist.
|
||||
$config->add_plugin_instance('storeconfigtest', 'shallowfail', array('test' => 'a', 'one' => 'two'));
|
||||
$config->add_store_instance('storeconfigtest', 'shallowfail', array('test' => 'a', 'one' => 'two'));
|
||||
$this->fail('You should not be able to add an instance of a store that does not exist.');
|
||||
} catch (Exception $e) {
|
||||
$this->assertInstanceOf('cache_exception', $e);
|
||||
@ -232,7 +232,7 @@ class cache_config_writer_phpunit_tests extends advanced_testcase {
|
||||
*/
|
||||
public function test_set_mode_mappings() {
|
||||
$config = cache_config_writer::instance();
|
||||
$this->assertTrue($config->add_plugin_instance('setmodetest', 'file'));
|
||||
$this->assertTrue($config->add_store_instance('setmodetest', 'file'));
|
||||
$this->assertTrue($config->set_mode_mappings(array(
|
||||
cache_store::MODE_APPLICATION => array('setmodetest', 'default_application'),
|
||||
cache_store::MODE_SESSION => array('default_session'),
|
||||
@ -260,7 +260,7 @@ class cache_config_writer_phpunit_tests extends advanced_testcase {
|
||||
));
|
||||
|
||||
$config = cache_config_writer::instance();
|
||||
$this->assertTrue($config->add_plugin_instance('setdefinitiontest', 'file'));
|
||||
$this->assertTrue($config->add_store_instance('setdefinitiontest', 'file'));
|
||||
$this->assertInternalType('array', $config->get_definition_by_id('phpunit/testdefinition'));
|
||||
$config->set_definition_mappings('phpunit/testdefinition', array('setdefinitiontest', 'default_application'));
|
||||
|
||||
@ -303,7 +303,7 @@ class cache_administration_helper_phpunit_tests extends advanced_testcase {
|
||||
public function test_get_summaries() {
|
||||
// First the preparation.
|
||||
$config = cache_config_writer::instance();
|
||||
$this->assertTrue($config->add_plugin_instance('summariesstore', 'file'));
|
||||
$this->assertTrue($config->add_store_instance('summariesstore', 'file'));
|
||||
$config->set_definition_mappings('core/eventinvalidation', array('summariesstore'));
|
||||
$this->assertTrue($config->set_mode_mappings(array(
|
||||
cache_store::MODE_APPLICATION => array('summariesstore'),
|
||||
@ -311,7 +311,7 @@ class cache_administration_helper_phpunit_tests extends advanced_testcase {
|
||||
cache_store::MODE_REQUEST => array('default_request'),
|
||||
)));
|
||||
|
||||
$storesummaries = cache_administration_helper::get_store_summaries();
|
||||
$storesummaries = cache_administration_helper::get_store_instance_summaries();
|
||||
$this->assertInternalType('array', $storesummaries);
|
||||
$this->assertArrayHasKey('summariesstore', $storesummaries);
|
||||
$summary = $storesummaries['summariesstore'];
|
||||
@ -352,7 +352,7 @@ class cache_administration_helper_phpunit_tests extends advanced_testcase {
|
||||
$this->assertInternalType('array', $summary['mappings']);
|
||||
$this->assertContains('summariesstore', $summary['mappings']);
|
||||
|
||||
$pluginsummaries = cache_administration_helper::get_plugin_summaries();
|
||||
$pluginsummaries = cache_administration_helper::get_store_plugin_summaries();
|
||||
$this->assertInternalType('array', $pluginsummaries);
|
||||
$this->assertArrayHasKey('file', $pluginsummaries);
|
||||
$summary = $pluginsummaries['file'];
|
||||
@ -403,7 +403,7 @@ class cache_administration_helper_phpunit_tests extends advanced_testcase {
|
||||
*/
|
||||
public function test_get_edit_store_form() {
|
||||
$config = cache_config_writer::instance();
|
||||
$this->assertTrue($config->add_plugin_instance('summariesstore', 'file'));
|
||||
$this->assertTrue($config->add_store_instance('summariesstore', 'file'));
|
||||
|
||||
$form = cache_administration_helper::get_edit_store_form('file', 'summariesstore');
|
||||
$this->assertInstanceOf('moodleform', $form);
|
||||
|
@ -85,7 +85,7 @@ $string['mode_4'] = 'Request';
|
||||
$string['nativelocking'] = 'This plugin handles its own locking.';
|
||||
$string['none'] = 'None';
|
||||
$string['plugin'] = 'Plugin';
|
||||
$string['pluginsummaries'] = 'Installed cache plugins';
|
||||
$string['pluginsummaries'] = 'Installed cache stores';
|
||||
$string['purge'] = 'Purge';
|
||||
$string['purgestoresuccess'] = 'Successfully purged the requested store.';
|
||||
$string['requestcount'] = 'Test with {$a} requests';
|
||||
@ -106,7 +106,7 @@ $string['stores'] = 'Stores';
|
||||
$string['store_default_application'] = 'Default file store for application caches';
|
||||
$string['store_default_request'] = 'Default static store for request caches';
|
||||
$string['store_default_session'] = 'Default session store for session caches';
|
||||
$string['storesummaries'] = 'Configured plugin instances';
|
||||
$string['storesummaries'] = 'Configured store instances';
|
||||
$string['supports'] = 'Supports';
|
||||
$string['supports_multipleidentifiers'] = 'multiple identifiers';
|
||||
$string['supports_dataguarantee'] = 'data guarantee';
|
||||
|
Loading…
x
Reference in New Issue
Block a user