MDL-66928 core: Move request dirs to system tmp instead of localcache
This commit is contained in:
@@ -476,6 +476,7 @@ $CFG->admin = 'admin';
|
||||
// $CFG->tempdir = '/var/www/moodle/temp'; // Directory MUST BE SHARED by all cluster nodes.
|
||||
// $CFG->cachedir = '/var/www/moodle/cache'; // Directory MUST BE SHARED by all cluster nodes, locking required.
|
||||
// $CFG->localcachedir = '/var/local/cache'; // Intended for local node caching.
|
||||
// $CFG->localrequestdir = '/tmp'; // Intended for local only temporary files. The defaults uses sys_get_temp_dir().
|
||||
//
|
||||
// It is possible to specify a different backup temp directory, use local fast filesystem
|
||||
// for normal web servers. Server clusters MUST use shared filesystem for backuptempdir!
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
* - $CFG->tempdir - Path to moodle's temp file directory on server's filesystem.
|
||||
* - $CFG->cachedir - Path to moodle's cache directory on server's filesystem (shared by cluster nodes).
|
||||
* - $CFG->localcachedir - Path to moodle's local cache directory (not shared by cluster nodes).
|
||||
* - $CFG->localrequestdir - Path to moodle's local temp request directory (not shared by cluster nodes).
|
||||
*
|
||||
* @global object $CFG
|
||||
* @name $CFG
|
||||
@@ -208,6 +209,11 @@ if (!isset($CFG->localcachedir)) {
|
||||
$CFG->localcachedir = "$CFG->dataroot/localcache";
|
||||
}
|
||||
|
||||
// Allow overriding of localrequestdir.
|
||||
if (!isset($CFG->localrequestdir)) {
|
||||
$CFG->localrequestdir = sys_get_temp_dir() . '/requestdir';
|
||||
}
|
||||
|
||||
// Location of all languages except core English pack.
|
||||
if (!isset($CFG->langotherroot)) {
|
||||
$CFG->langotherroot = $CFG->dataroot.'/lang';
|
||||
|
||||
+4
-7
@@ -1635,14 +1635,11 @@ function get_request_storage_directory($exceptiononerror = true, bool $forcecrea
|
||||
$createnewdirectory = $forcecreate || !$writabledirectoryexists;
|
||||
|
||||
if ($createnewdirectory) {
|
||||
if ($CFG->localcachedir !== "$CFG->dataroot/localcache") {
|
||||
check_dir_exists($CFG->localcachedir, true, true);
|
||||
protect_directory($CFG->localcachedir);
|
||||
} else {
|
||||
protect_directory($CFG->dataroot);
|
||||
}
|
||||
$basedir = "{$CFG->localrequestdir}/{$CFG->siteidentifier}";
|
||||
make_writable_directory($basedir);
|
||||
protect_directory($basedir);
|
||||
|
||||
if ($dir = make_unique_writable_directory($CFG->localcachedir, $exceptiononerror)) {
|
||||
if ($dir = make_unique_writable_directory($basedir, $exceptiononerror)) {
|
||||
// Register a shutdown handler to remove the directory.
|
||||
\core_shutdown_manager::register_function('remove_dir', [$dir]);
|
||||
}
|
||||
|
||||
@@ -204,6 +204,8 @@ class core_setuplib_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_get_request_storage_directory() {
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
// Making a call to get_request_storage_directory should always give the same result.
|
||||
$firstdir = get_request_storage_directory();
|
||||
$seconddir = get_request_storage_directory();
|
||||
@@ -230,6 +232,11 @@ class core_setuplib_testcase extends advanced_testcase {
|
||||
$fourthdir = get_request_storage_directory();
|
||||
$this->assertTrue(is_dir($fourthdir));
|
||||
$this->assertNotEquals($thirddir, $fourthdir);
|
||||
|
||||
$now = $this->setCurrentTimeStart();
|
||||
set_config('localcachedirpurged', $now - 2);
|
||||
purge_all_caches();
|
||||
$this->assertTrue(is_dir($fourthdir));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ information provided here is intended especially for developers.
|
||||
renamed to `is_listed()` and `get_not_listed()` respectively.
|
||||
* Method `mustache_helper_collection::strip_blacklisted_helpers()` has been deprecated and renamed to
|
||||
`strip_disallowed_helpers()`.
|
||||
* New setting $CFG->localtempdir overrides which defaults to sys_get_temp_dir()
|
||||
|
||||
=== 3.9 ===
|
||||
* Following function has been deprecated, please use \core\task\manager::run_from_cli().
|
||||
|
||||
Reference in New Issue
Block a user