From 12812ad5da77a672c3798fdd345ca4ae26857f2d Mon Sep 17 00:00:00 2001 From: David Mudrak Date: Mon, 21 Nov 2011 11:49:51 +0100 Subject: [PATCH 1/3] MDL-30381 Fixed path to the cache directory in installers This fixes the patch f848c0f6e60c4451a0058d87194f326bca690c1e introduced in MDL-29351. --- admin/cli/install.php | 2 +- install.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/admin/cli/install.php b/admin/cli/install.php index 68ed892f467..2ecb49b6de9 100644 --- a/admin/cli/install.php +++ b/admin/cli/install.php @@ -135,7 +135,7 @@ $CFG->wwwroot = "http://localhost"; $CFG->httpswwwroot = $CFG->wwwroot; $CFG->dataroot = str_replace('\\', '/', dirname(dirname(dirname(dirname(__FILE__)))).'/moodledata'); $CFG->tempdir = $CFG->dataroot.'/temp'; -$CFG->cachedir = $CFG->dataroot.'/temp'; +$CFG->cachedir = $CFG->dataroot.'/cache'; $CFG->docroot = 'http://docs.moodle.org'; $CFG->running_installer = true; $CFG->early_install_lang = true; diff --git a/install.php b/install.php index 533c7aebd02..341a1472d27 100644 --- a/install.php +++ b/install.php @@ -166,7 +166,7 @@ $CFG->wwwroot = install_guess_wwwroot(); // can not be changed - pp $CFG->httpswwwroot = $CFG->wwwroot; $CFG->dataroot = $config->dataroot; $CFG->tempdir = $CFG->dataroot.'/temp'; -$CFG->cachedir = $CFG->dataroot.'/temp'; +$CFG->cachedir = $CFG->dataroot.'/cache'; $CFG->admin = $config->admin; $CFG->docroot = 'http://docs.moodle.org'; $CFG->langotherroot = $CFG->dataroot.'/lang'; From b907d3f58cdfc70ca2f0fd3b83e41fa21e48a1a4 Mon Sep 17 00:00:00 2001 From: David Mudrak Date: Mon, 21 Nov 2011 16:01:18 +0100 Subject: [PATCH 2/3] MDL-30381 Fixed the tempdir and cachedir value calculation Instead of using the default dataroot location, the tempdir and cachedir are now set under the real dataroot location specified via the argument and/or the interactive session. The patch also adds a PARAM_PATH check for the dataroot specified. --- admin/cli/install.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/admin/cli/install.php b/admin/cli/install.php index 2ecb49b6de9..1b37313d5ac 100644 --- a/admin/cli/install.php +++ b/admin/cli/install.php @@ -133,9 +133,6 @@ $CFG->dirroot = dirname(dirname(dirname(__FILE__))); $CFG->libdir = "$CFG->dirroot/lib"; $CFG->wwwroot = "http://localhost"; $CFG->httpswwwroot = $CFG->wwwroot; -$CFG->dataroot = str_replace('\\', '/', dirname(dirname(dirname(dirname(__FILE__)))).'/moodledata'); -$CFG->tempdir = $CFG->dataroot.'/temp'; -$CFG->cachedir = $CFG->dataroot.'/cache'; $CFG->docroot = 'http://docs.moodle.org'; $CFG->running_installer = true; $CFG->early_install_lang = true; @@ -186,7 +183,7 @@ list($options, $unrecognized) = cli_get_params( 'chmod' => '2777', 'lang' => $CFG->lang, 'wwwroot' => '', - 'dataroot' => $CFG->dataroot, + 'dataroot' => str_replace('\\', '/', dirname(dirname(dirname(dirname(__FILE__)))).'/moodledata'), 'dbtype' => $defaultdb, 'dbhost' => 'localhost', 'dbname' => 'moodle', @@ -330,9 +327,12 @@ $CFG->httpswwwroot = $CFG->wwwroot; //We need dataroot before lang download -if (!empty($options['dataroot'])) { - $CFG->dataroot = $options['dataroot']; +$dataroot = clean_param($options['dataroot'], PARAM_PATH); +if ($dataroot !== $options['dataroot']) { + $a = (object)array('option' => 'dataroot', 'value' => $options['dataroot']); + cli_error(get_string('cliincorrectvalueerror', 'admin', $a)); } +$CFG->dataroot = $dataroot; if ($interactive) { cli_separator(); $i=0; @@ -380,6 +380,8 @@ if ($interactive) { cli_error(get_string('pathserrcreatedataroot', 'install', $a)); } } +$CFG->tempdir = $CFG->dataroot.'/temp'; +$CFG->cachedir = $CFG->dataroot.'/cache'; // download required lang packs if ($CFG->lang !== 'en') { From fbe33209ce30131bb481f99b18d3ef0b155fbce9 Mon Sep 17 00:00:00 2001 From: David Mudrak Date: Mon, 21 Nov 2011 16:49:40 +0100 Subject: [PATCH 3/3] MDL-30381 install_init_dataroot() now creates temp and cache This prevents PHP warnings displayed due to recent modifications in make_temp_dir() and make_cache_dir(). These functions now expect that the root temp/cache dir already exists. So they must be available before the lang_installer installs the lang pack during install. --- lib/installlib.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/installlib.php b/lib/installlib.php index c6cb423c187..566bc8cb3c6 100644 --- a/lib/installlib.php +++ b/lib/installlib.php @@ -106,7 +106,27 @@ function install_init_dataroot($dataroot, $dirpermissions) { return false; // we can not continue } - // now create the lang folder - we need it and it makes sure we can really write in dataroot + // create the directory for $CFG->tempdir + if (!is_dir("$dataroot/temp")) { + if (!mkdir("$dataroot/temp", $dirpermissions, true)) { + return false; + } + } + if (!is_writable("$dataroot/temp")) { + return false; // we can not continue + } + + // create the directory for $CFG->cachedir + if (!is_dir("$dataroot/cache")) { + if (!mkdir("$dataroot/cache", $dirpermissions, true)) { + return false; + } + } + if (!is_writable("$dataroot/cache")) { + return false; // we can not continue + } + + // create the directory for $CFG->langotherroot if (!is_dir("$dataroot/lang")) { if (!mkdir("$dataroot/lang", $dirpermissions, true)) { return false;