/** * Finds all definitions and updates them within the cache config file. * * @param bool $coreonly If set to true only core definitions will be updated. */ public static function update_definitions($coreonly = false) { global $CFG; // Include locallib. require_once $CFG->dirroot . '/cache/locallib.php'; // First update definitions cache_config_writer::update_definitions($coreonly); // Second reset anything we have already initialised to ensure we're all up to date. cache_factory::reset(); }
/** * Test updating the definitions. */ public function test_update_definitions() { $config = cache_config_writer::instance(); $earlydefinitions = $config->get_definitions(); unset($config); cache_factory::reset(); cache_config_writer::update_definitions(); $config = cache_config_writer::instance(); $latedefinitions = $config->get_definitions(); $this->assertSame($latedefinitions, $earlydefinitions); }
admin_externalpage_setup('cacheconfig'); $context = context_system::instance(); $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(); $title = new lang_string('cacheadmin', 'cache'); $mform = null; $notification = null; $notifysuccess = true; if (!empty($action) && confirm_sesskey()) { switch ($action) { case 'rescandefinitions': // Rescan definitions. cache_config_writer::update_definitions(); redirect($PAGE->url); break; case 'addstore': // Add the requested store. $plugin = required_param('plugin', PARAM_PLUGIN); if (!$plugins[$plugin]['canaddinstance']) { print_error('ex_unmetstorerequirements', 'cache'); } $mform = cache_administration_helper::get_add_store_form($plugin); $title = get_string('addstore', 'cache', $plugins[$plugin]['name']); if ($mform->is_cancelled()) { redirect($PAGE->url); } else { if ($data = $mform->get_data()) { $config = cache_administration_helper::get_store_configuration_from_data($data);
/** * Test updating the definitions. */ public function test_update_definitions() { $config = cache_config_writer::instance(); // Remove the definition. $config->phpunit_remove_definition('core/string'); $definitions = $config->get_definitions(); // Check it is gone. $this->assertFalse(array_key_exists('core/string', $definitions)); // Update definitions. This should re-add it. cache_config_writer::update_definitions(); $definitions = $config->get_definitions(); // Check it is back again. $this->assertTrue(array_key_exists('core/string', $definitions)); }