本文整理汇总了PHP中cache_helper::purge_all方法的典型用法代码示例。如果您正苦于以下问题:PHP cache_helper::purge_all方法的具体用法?PHP cache_helper::purge_all怎么用?PHP cache_helper::purge_all使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cache_helper
的用法示例。
在下文中一共展示了cache_helper::purge_all方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reset_dataroot
/**
* Purge dataroot directory
* @static
* @return void
*/
public static function reset_dataroot() {
global $CFG;
$childclassname = self::get_framework() . '_util';
$handle = opendir($CFG->dataroot);
while (false !== ($item = readdir($handle))) {
if (in_array($item, $childclassname::$datarootskiponreset)) {
continue;
}
if (is_dir("$CFG->dataroot/$item")) {
remove_dir("$CFG->dataroot/$item", false);
} else {
unlink("$CFG->dataroot/$item");
}
}
closedir($handle);
make_temp_directory('');
make_cache_directory('');
make_cache_directory('htmlpurifier');
// Reset the cache API so that it recreates it's required directories as well.
cache_factory::reset();
// Purge all data from the caches. This is required for consistency.
// Any file caches that happened to be within the data root will have already been clearer (because we just deleted cache)
// and now we will purge any other caches as well.
cache_helper::purge_all();
}
示例2: store_response
/**
* Stores the valid fetched response for later usage
*
* This implementation uses the config_plugins table as the permanent storage.
*
* @param string $response raw valid data returned by {@link self::get_response()}
*/
protected function store_response($response)
{
set_config('recentfetch', time(), 'core_plugin');
set_config('recentresponse', $response, 'core_plugin');
if (defined('CACHE_DISABLE_ALL') and CACHE_DISABLE_ALL) {
// Very nasty hack to work around cache coherency issues on admin/index.php?cache=0 page,
// we definitely need to keep caches in sync when writing into DB at all times!
cache_helper::purge_all(true);
}
$this->restore_response(true);
}
示例3: upgrade_noncore
/**
* Upgrade/install other parts of moodle
* @param bool $verbose
* @return void, may throw exception
*/
function upgrade_noncore($verbose) {
global $CFG;
raise_memory_limit(MEMORY_EXTRA);
// upgrade all plugins types
try {
// Reset caches before any output.
cache_helper::purge_all(true);
purge_all_caches();
$plugintypes = core_component::get_plugin_types();
foreach ($plugintypes as $type=>$location) {
upgrade_plugins($type, 'print_upgrade_part_start', 'print_upgrade_part_end', $verbose);
}
// Update cache definitions. Involves scanning each plugin for any changes.
cache_helper::update_definitions();
// Mark the site as upgraded.
set_config('allversionshash', core_component::get_all_versions_hash());
// Purge caches again, just to be sure we arn't holding onto old stuff now.
cache_helper::purge_all(true);
purge_all_caches();
} catch (Exception $ex) {
upgrade_handle_exception($ex);
}
}
示例4: 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();
}
示例5: purge_all_caches
purge_all_caches();
redirect(new moodle_url('/admin/index.php'), 'Config cache inconsistency detected, resetting caches...');
}
if (!$cache and $version > $CFG->version) {
// upgrade
// Warning about upgrading a test site.
$testsite = false;
if (defined('BEHAT_SITE_RUNNING')) {
$testsite = 'behat';
}
// We purge all of MUC's caches here.
// Caches are disabled for upgrade by CACHE_DISABLE_ALL so we must set the first arg to true.
// This ensures a real config object is loaded and the stores will be purged.
// This is the only way we can purge custom caches such as memcache or APC.
// Note: all other calls to caches will still used the disabled API.
cache_helper::purge_all(true);
// We then purge the regular caches.
purge_all_caches();
/** @var core_admin_renderer $output */
$output = $PAGE->get_renderer('core', 'admin');
if (upgrade_stale_php_files_present()) {
$PAGE->set_title($stradministration);
$PAGE->set_cacheable(false);
echo $output->upgrade_stale_php_files_page();
die;
}
if (empty($confirmupgrade)) {
$a = new stdClass();
$a->oldversion = "{$CFG->release} (" . sprintf('%.2f', $CFG->version) . ")";
$a->newversion = "{$release} (" . sprintf('%.2f', $version) . ")";
$strdatabasechecking = get_string('databasechecking', '', $a);
示例6: reset_dataroot
/**
* Purge dataroot directory
* @static
* @return void
*/
public static function reset_dataroot()
{
global $CFG;
$childclassname = self::get_framework() . '_util';
// Do not delete automatically installed files.
self::skip_original_data_files($childclassname);
// Clear file status cache, before checking file_exists.
clearstatcache();
// Clean up the dataroot folder.
$handle = opendir(self::get_dataroot());
while (false !== ($item = readdir($handle))) {
if (in_array($item, $childclassname::$datarootskiponreset)) {
continue;
}
if (is_dir(self::get_dataroot() . "/{$item}")) {
remove_dir(self::get_dataroot() . "/{$item}", false);
} else {
unlink(self::get_dataroot() . "/{$item}");
}
}
closedir($handle);
// Clean up the dataroot/filedir folder.
if (file_exists(self::get_dataroot() . '/filedir')) {
$handle = opendir(self::get_dataroot() . '/filedir');
while (false !== ($item = readdir($handle))) {
if (in_array('filedir/' . $item, $childclassname::$datarootskiponreset)) {
continue;
}
if (is_dir(self::get_dataroot() . "/filedir/{$item}")) {
remove_dir(self::get_dataroot() . "/filedir/{$item}", false);
} else {
unlink(self::get_dataroot() . "/filedir/{$item}");
}
}
closedir($handle);
}
make_temp_directory('');
make_cache_directory('');
make_localcache_directory('');
// Reset the cache API so that it recreates it's required directories as well.
cache_factory::reset();
// Purge all data from the caches. This is required for consistency.
// Any file caches that happened to be within the data root will have already been clearer (because we just deleted cache)
// and now we will purge any other caches as well.
cache_helper::purge_all();
}
示例7: upgrade_noncore
/**
* Upgrade/install other parts of moodle
* @param bool $verbose
* @return void, may throw exception
*/
function upgrade_noncore($verbose)
{
global $CFG;
raise_memory_limit(MEMORY_EXTRA);
// upgrade all plugins types
try {
// Reset caches before any output.
cache_helper::purge_all(true);
purge_all_caches();
$plugintypes = core_component::get_plugin_types();
foreach ($plugintypes as $type => $location) {
upgrade_plugins($type, 'print_upgrade_part_start', 'print_upgrade_part_end', $verbose);
}
// Upgrade services.
// This function gives plugins and subsystems a chance to add functions to existing built-in services.
external_update_services();
// Update cache definitions. Involves scanning each plugin for any changes.
cache_helper::update_definitions();
// Mark the site as upgraded.
set_config('allversionshash', core_component::get_all_versions_hash());
// Purge caches again, just to be sure we arn't holding onto old stuff now.
cache_helper::purge_all(true);
purge_all_caches();
} catch (Exception $ex) {
upgrade_handle_exception($ex);
} catch (Throwable $ex) {
// Engine errors in PHP7 throw exceptions of type Throwable (this "catch" will be ignored in PHP5).
upgrade_handle_exception($ex);
}
}
示例8: 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
* {@see phpunit_util::reset_dataroot()}
*
* @return void
*/
function purge_all_caches()
{
global $CFG;
reset_text_filters_cache();
js_reset_all_caches();
theme_reset_all_caches();
get_string_manager()->reset_caches();
textlib::reset_caches();
cache_helper::purge_all();
// purge all other caches: rss, simplepie, etc.
remove_dir($CFG->cachedir . '', true);
// make sure cache dir is writable, throws exception if not
make_cache_directory('');
// hack: this script may get called after the purifier was initialised,
// but we do not want to verify repeatedly this exists in each call
make_cache_directory('htmlpurifier');
}
示例9: upgrade_core
/**
* Upgrade moodle core
* @param float $version target version
* @param bool $verbose
* @return void, may throw exception
*/
function upgrade_core($version, $verbose) {
global $CFG;
raise_memory_limit(MEMORY_EXTRA);
require_once($CFG->libdir.'/db/upgrade.php'); // Defines upgrades
try {
// Reset caches before any output
purge_all_caches();
cache_helper::purge_all(true);
// Upgrade current language pack if we can
upgrade_language_pack();
print_upgrade_part_start('moodle', false, $verbose);
// Pre-upgrade scripts for local hack workarounds.
$preupgradefile = "$CFG->dirroot/local/preupgrade.php";
if (file_exists($preupgradefile)) {
set_time_limit(0);
require($preupgradefile);
// Reset upgrade timeout to default.
upgrade_set_timeout();
}
$result = xmldb_main_upgrade($CFG->version);
if ($version > $CFG->version) {
// store version if not already there
upgrade_main_savepoint($result, $version, false);
}
// perform all other component upgrade routines
update_capabilities('moodle');
log_update_descriptions('moodle');
external_update_descriptions('moodle');
events_update_definition('moodle');
message_update_providers('moodle');
// Update core definitions.
cache_helper::update_definitions(true);
// Purge caches again, just to be sure we arn't holding onto old stuff now.
purge_all_caches();
cache_helper::purge_all(true);
// Clean up contexts - more and more stuff depends on existence of paths and contexts
context_helper::cleanup_instances();
context_helper::create_instances(null, false);
context_helper::build_all_paths(false);
$syscontext = context_system::instance();
$syscontext->mark_dirty();
print_upgrade_part_end('moodle', false, $verbose);
} catch (Exception $ex) {
upgrade_handle_exception($ex);
}
}
示例10: reset_dataroot
/**
* Purge dataroot directory
* @static
* @return void
*/
public static function reset_dataroot()
{
global $CFG;
$handle = opendir($CFG->dataroot);
$skip = array('.', '..', 'phpunittestdir.txt', 'phpunit', '.htaccess');
while (false !== ($item = readdir($handle))) {
if (in_array($item, $skip)) {
continue;
}
if (is_dir("{$CFG->dataroot}/{$item}")) {
remove_dir("{$CFG->dataroot}/{$item}", false);
} else {
unlink("{$CFG->dataroot}/{$item}");
}
}
closedir($handle);
make_temp_directory('');
make_cache_directory('');
make_cache_directory('htmlpurifier');
// Reset the cache API so that it recreates it's required directories as well.
cache_factory::reset();
// Purge all data from the caches. This is required for consistency.
// Any file caches that happened to be within the data root will have already been clearer (because we just deleted cache)
// and now we will purge any other caches as well.
cache_helper::purge_all();
}
示例11: install_core
/**
* Install core moodle tables and initialize
* @param float $version target version
* @param bool $verbose
* @return void, may throw exception
*/
function install_core($version, $verbose) {
global $CFG, $DB;
try {
// Disable the use of cache stores here. We will reset the factory after we've performed the installation.
// This ensures that we don't permanently cache anything during installation.
cache_factory::disable_stores();
set_time_limit(600);
print_upgrade_part_start('moodle', true, $verbose); // does not store upgrade running flag
$DB->get_manager()->install_from_xmldb_file("$CFG->libdir/db/install.xml");
upgrade_started(); // we want the flag to be stored in config table ;-)
// set all core default records and default settings
require_once("$CFG->libdir/db/install.php");
xmldb_main_install(); // installs the capabilities too
// store version
upgrade_main_savepoint(true, $version, false);
// Continue with the installation
log_update_descriptions('moodle');
external_update_descriptions('moodle');
events_update_definition('moodle');
message_update_providers('moodle');
// Write default settings unconditionally
admin_apply_default_settings(NULL, true);
print_upgrade_part_end(null, true, $verbose);
// Purge all caches. They're disabled but this ensures that we don't have any persistent data just in case something
// during installation didn't use APIs.
cache_helper::purge_all();
} catch (exception $ex) {
upgrade_handle_exception($ex);
}
}