MDL-76129 upgrade: Allow caching in specific functions

During install/upgrade, caching is disabled. This change provides a
way to temporarily enable caching (using in-memory cache storage only)
within a specific function; caches are deleted afterwards.

Adding this to two locations improves install performance quite a lot.

Caching is not enabled during the parts of plugin installation that
can vary for individual plugins (install.php/upgrade.php) as these
might be relying on its absence, for example by making direct database
changes.
This commit is contained in:
sam marshall
2022-11-01 15:19:46 +00:00
parent 7724e543ff
commit 0b2c2a1f95
5 changed files with 179 additions and 0 deletions

View File

@@ -8852,6 +8852,10 @@ function admin_get_root($reload=false, $requirefulltree=true) {
function admin_apply_default_settings($node=null, $unconditional=true, $admindefaultsettings=array(), $settingsoutput=array()) {
$counter = 0;
// This function relies heavily on config cache, so we need to enable in-memory caches if it
// is used during install when normal caching is disabled.
$token = new \core_cache\allow_temporary_caches();
if (is_null($node)) {
core_plugin_manager::reset_caches();
$node = admin_get_root(true, true);