本文整理汇总了PHP中core_plugin_manager::reset_caches方法的典型用法代码示例。如果您正苦于以下问题:PHP core_plugin_manager::reset_caches方法的具体用法?PHP core_plugin_manager::reset_caches怎么用?PHP core_plugin_manager::reset_caches使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_plugin_manager
的用法示例。
在下文中一共展示了core_plugin_manager::reset_caches方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reset_all_data
/**
* Reset contents of all database tables to initial values, reset caches, etc.
*
* Note: this is relatively slow (cca 2 seconds for pg and 7 for mysql) - please use with care!
*
* @static
* @param bool $detectchanges
* true - changes in global state and database are reported as errors
* false - no errors reported
* null - only critical problems are reported as errors
* @return void
*/
public static function reset_all_data($detectchanges = false)
{
global $DB, $CFG, $USER, $SITE, $COURSE, $PAGE, $OUTPUT, $SESSION;
// Stop any message redirection.
phpunit_util::stop_message_redirection();
// Stop any message redirection.
phpunit_util::stop_phpmailer_redirection();
// Stop any message redirection.
phpunit_util::stop_event_redirection();
// We used to call gc_collect_cycles here to ensure desctructors were called between tests.
// This accounted for 25% of the total time running phpunit - so we removed it.
// Show any unhandled debugging messages, the runbare() could already reset it.
self::display_debugging_messages();
self::reset_debugging();
// reset global $DB in case somebody mocked it
$DB = self::get_global_backup('DB');
if ($DB->is_transaction_started()) {
// we can not reset inside transaction
$DB->force_transaction_rollback();
}
$resetdb = self::reset_database();
$warnings = array();
if ($detectchanges === true) {
if ($resetdb) {
$warnings[] = 'Warning: unexpected database modification, resetting DB state';
}
$oldcfg = self::get_global_backup('CFG');
$oldsite = self::get_global_backup('SITE');
foreach ($CFG as $k => $v) {
if (!property_exists($oldcfg, $k)) {
$warnings[] = 'Warning: unexpected new $CFG->' . $k . ' value';
} else {
if ($oldcfg->{$k} !== $CFG->{$k}) {
$warnings[] = 'Warning: unexpected change of $CFG->' . $k . ' value';
}
}
unset($oldcfg->{$k});
}
if ($oldcfg) {
foreach ($oldcfg as $k => $v) {
$warnings[] = 'Warning: unexpected removal of $CFG->' . $k;
}
}
if ($USER->id != 0) {
$warnings[] = 'Warning: unexpected change of $USER';
}
if ($COURSE->id != $oldsite->id) {
$warnings[] = 'Warning: unexpected change of $COURSE';
}
}
if (ini_get('max_execution_time') != 0) {
// This is special warning for all resets because we do not want any
// libraries to mess with timeouts unintentionally.
// Our PHPUnit integration is not supposed to change it either.
if ($detectchanges !== false) {
$warnings[] = 'Warning: max_execution_time was changed to ' . ini_get('max_execution_time');
}
set_time_limit(0);
}
// restore original globals
$_SERVER = self::get_global_backup('_SERVER');
$CFG = self::get_global_backup('CFG');
$SITE = self::get_global_backup('SITE');
$_GET = array();
$_POST = array();
$_FILES = array();
$_REQUEST = array();
$COURSE = $SITE;
// reinitialise following globals
$OUTPUT = new bootstrap_renderer();
$PAGE = new moodle_page();
$FULLME = null;
$ME = null;
$SCRIPT = null;
// Empty sessison and set fresh new not-logged-in user.
\core\session\manager::init_empty_session();
// reset all static caches
\core\event\manager::phpunit_reset();
accesslib_clear_all_caches(true);
get_string_manager()->reset_caches(true);
reset_text_filters_cache(true);
events_get_handlers('reset');
core_text::reset_caches();
get_message_processors(false, true);
filter_manager::reset_caches();
// Reset internal users.
core_user::reset_internal_users();
//TODO MDL-25290: add more resets here and probably refactor them to new core function
//.........这里部分代码省略.........
示例2: enable_plugin
/**
* Creates a new instance of the portfolio plugin
*
* @param string $name name of the instance
* @param stdClass $data config data for the instance
* @return portfolio_plugin_base
*/
protected function enable_plugin($name = 'Instance name', $data = null)
{
$data = $data ?: new stdClass();
$instance = portfolio_static_function($this->pluginname, 'create_instance', $this->pluginname, $name, $data);
core_plugin_manager::reset_caches();
return $instance;
}
示例3: admin_apply_default_settings
/**
* This function applies default settings.
*
* @param object $node, NULL means complete tree, null by default
* @param bool $unconditional if true overrides all values with defaults, null buy default
*/
function admin_apply_default_settings($node = NULL, $unconditional = true)
{
global $CFG;
if (is_null($node)) {
core_plugin_manager::reset_caches();
$node = admin_get_root(true, true);
}
if ($node instanceof admin_category) {
$entries = array_keys($node->children);
foreach ($entries as $entry) {
admin_apply_default_settings($node->children[$entry], $unconditional);
}
} else {
if ($node instanceof admin_settingpage) {
foreach ($node->settings as $setting) {
if (!$unconditional and !is_null($setting->get_setting())) {
//do not override existing defaults
continue;
}
$defaultsetting = $setting->get_defaultsetting();
if (is_null($defaultsetting)) {
// no value yet - default maybe applied after admin user creation or in upgradesettings
continue;
}
$setting->write_setting($defaultsetting);
$setting->write_setting_flags(null);
}
}
}
// Just in case somebody modifies the list of active plugins directly.
core_plugin_manager::reset_caches();
}
示例4: print_error
if (!($block = $DB->get_record('block', array('id' => $hide)))) {
print_error('blockdoesnotexist', 'error');
}
$DB->set_field('block', 'visible', '0', array('id' => $block->id));
// Hide block
core_plugin_manager::reset_caches();
admin_get_root(true, false);
// settings not required - only pages
}
if (!empty($show) && confirm_sesskey()) {
if (!($block = $DB->get_record('block', array('id' => $show)))) {
print_error('blockdoesnotexist', 'error');
}
$DB->set_field('block', 'visible', '1', array('id' => $block->id));
// Show block
core_plugin_manager::reset_caches();
admin_get_root(true, false);
// settings not required - only pages
}
if (!isset($CFG->undeletableblocktypes) || !is_array($CFG->undeletableblocktypes) && !is_string($CFG->undeletableblocktypes)) {
$undeletableblocktypes = array('navigation', 'settings');
} else {
if (is_string($CFG->undeletableblocktypes)) {
$undeletableblocktypes = explode(',', $CFG->undeletableblocktypes);
} else {
$undeletableblocktypes = $CFG->undeletableblocktypes;
}
}
if (!empty($protect) && confirm_sesskey()) {
if (!($block = $DB->get_record('block', array('id' => $protect)))) {
print_error('blockdoesnotexist', 'error');
示例5: purge_all_caches
/**
* Invalidates browser caches and cached data in temp.
*
* IMPORTANT - If you are adding anything here to do with the cache directory you should also have a look at
* {@link phpunit_util::reset_dataroot()}
*
* @return void
*/
function purge_all_caches()
{
global $CFG, $DB;
reset_text_filters_cache();
js_reset_all_caches();
theme_reset_all_caches();
get_string_manager()->reset_caches();
core_text::reset_caches();
if (class_exists('core_plugin_manager')) {
core_plugin_manager::reset_caches();
}
// Bump up cacherev field for all courses.
try {
increment_revision_number('course', 'cacherev', '');
} catch (moodle_exception $e) {
// Ignore exception since this function is also called before upgrade script when field course.cacherev does not exist yet.
}
$DB->reset_caches();
cache_helper::purge_all();
// Purge all other caches: rss, simplepie, etc.
clearstatcache();
remove_dir($CFG->cachedir . '', true);
// Make sure cache dir is writable, throws exception if not.
make_cache_directory('');
// This is the only place where we purge local caches, we are only adding files there.
// The $CFG->localcachedirpurged flag forces local directories to be purged on cluster nodes.
remove_dir($CFG->localcachedir, true);
set_config('localcachedirpurged', time());
make_localcache_directory('', true);
\core\task\manager::clear_static_caches();
}
示例6: fetch
/**
* Fetches the available update status from the remote site
*
* @throws checker_exception
*/
public function fetch()
{
$response = $this->get_response();
$this->validate_response($response);
$this->store_response($response);
// We need to reset plugin manager's caches - the currently existing
// singleton is not aware of eventually available updates we just fetched.
\core_plugin_manager::reset_caches();
}
示例7: test_plugin_states
public function test_plugin_states()
{
global $CFG;
$this->resetAfterTest();
// Any standard plugin that is ok.
$this->assertFileExists("{$CFG->dirroot}/mod/assign", 'assign module is not present');
$this->assertFileExists("{$CFG->dirroot}/mod/forum", 'forum module is not present');
$this->assertFileExists("{$CFG->dirroot}/{$CFG->admin}/tool/phpunit", 'phpunit tool is not present');
$this->assertFileNotExists("{$CFG->dirroot}/mod/xxxxxxx");
$this->assertFileNotExists("{$CFG->dirroot}/enrol/autorize");
// Ready for upgrade.
$assignversion = get_config('mod_assign', 'version');
set_config('version', $assignversion - 1, 'mod_assign');
// Downgrade problem.
$forumversion = get_config('mod_forum', 'version');
set_config('version', $forumversion + 1, 'mod_forum');
// Not installed yet.
unset_config('version', 'tool_phpunit');
// Missing already installed.
set_config('version', 2013091300, 'mod_xxxxxxx');
// Deleted present.
set_config('version', 2013091300, 'enrol_authorize');
core_plugin_manager::reset_caches();
$plugininfos = core_plugin_manager::instance()->get_plugins();
foreach ($plugininfos as $type => $infos) {
foreach ($infos as $name => $info) {
/** @var core\plugininfo\base $info */
if ($info->component === 'mod_assign') {
$this->assertSame(core_plugin_manager::PLUGIN_STATUS_UPGRADE, $info->get_status(), 'Invalid ' . $info->component . ' state');
} else {
if ($info->component === 'mod_forum') {
$this->assertSame(core_plugin_manager::PLUGIN_STATUS_DOWNGRADE, $info->get_status(), 'Invalid ' . $info->component . ' state');
} else {
if ($info->component === 'tool_phpunit') {
$this->assertSame(core_plugin_manager::PLUGIN_STATUS_NEW, $info->get_status(), 'Invalid ' . $info->component . ' state');
} else {
if ($info->component === 'mod_xxxxxxx') {
$this->assertSame(core_plugin_manager::PLUGIN_STATUS_MISSING, $info->get_status(), 'Invalid ' . $info->component . ' state');
} else {
if ($info->component === 'enrol_authorize') {
$this->assertSame(core_plugin_manager::PLUGIN_STATUS_DELETE, $info->get_status(), 'Invalid ' . $info->component . ' state');
} else {
$this->assertSame(core_plugin_manager::PLUGIN_STATUS_UPTODATE, $info->get_status(), 'Invalid ' . $info->component . ' state');
}
}
}
}
}
}
}
}
示例8: show_plugin
/**
* Show this plugin.
*
* @param string $plugin - The plugin to show
* @return string The next page to display
*/
public function show_plugin($plugin)
{
set_config('disabled', 0, $this->subtype . '_' . $plugin);
core_plugin_manager::reset_caches();
return 'view';
}