Skip to content

Commit

Permalink
MDL-28701 Change all uses of $CFG->dataroot/cache to $CFG->cachedir
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlanyon authored and skodak committed Sep 10, 2011
1 parent 383d388 commit 365bec4
Show file tree
Hide file tree
Showing 16 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions blog/rsslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ function blog_rss_file_name($type, $id, $tagid=0) {
global $CFG;

if ($tagid) {
return "$CFG->dataroot/cache/rss/blog/$type/$id/$tagid.xml";
return "$CFG->cachedir/rss/blog/$type/$id/$tagid.xml";
} else {
return "$CFG->dataroot/cache/rss/blog/$type/$id.xml";
return "$CFG->cachedir/rss/blog/$type/$id.xml";
}
}

Expand Down
2 changes: 1 addition & 1 deletion config-dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@
// If $CFG->langstringcache is enabled (which should always be in production
// environment), Moodle keeps aggregated strings in its own internal format
// optimised for performance. By default, this on-disk cache is created in
// $CFG->dataroot/cache/lang. In cluster environment, you may wish to specify
// $CFG->cachedir/lang. In cluster environment, you may wish to specify
// an alternative location of this cache so that each web server in the cluster
// uses its own local cache and does not need to access the shared dataroot.
// Make sure that the web server process has write permission to this location
Expand Down
2 changes: 1 addition & 1 deletion lib/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function xmldb_main_upgrade($oldversion) {
}

if ($oldversion < 2008030602) {
@unlink($CFG->dataroot.'/cache/languages');
@unlink($CFG->cachedir.'/languages');

if (file_exists("$CFG->dataroot/lang")) {
// rename old lang directory so that the new and old langs do not mix
Expand Down
4 changes: 2 additions & 2 deletions lib/filelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2935,9 +2935,9 @@ class curl_cache {
function __construct($module = 'repository'){
global $CFG;
if (!empty($module)) {
$this->dir = $CFG->dataroot.'/cache/'.$module.'/';
$this->dir = $CFG->cachedir.'/'.$module.'/';
} else {
$this->dir = $CFG->dataroot.'/cache/misc/';
$this->dir = $CFG->cachedir.'/misc/';
}
if (!file_exists($this->dir)) {
mkdir($this->dir, $CFG->directorypermissions, true);
Expand Down
2 changes: 1 addition & 1 deletion lib/javascript.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
function minify($files) {
global $CFG;

$cachedir = $CFG->dataroot.'/cache/js';
$cachedir = $CFG->cachedir.'/js';
// make sure the cache dir exist
if (!file_exists($cachedir)) {
@mkdir($cachedir, $CFG->directorypermissions, true);
Expand Down
6 changes: 3 additions & 3 deletions lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1370,7 +1370,7 @@ function purge_all_caches() {
get_string_manager()->reset_caches();

// purge all other caches: rss, simplepie, etc.
remove_dir($CFG->dataroot.'/cache', true);
remove_dir($CFG->cachedir.'', true);

// make sure cache dir is writable, throws exception if not
make_upload_directory('cache');
Expand Down Expand Up @@ -5685,7 +5685,7 @@ function get_string_manager($forcereload=false) {
if (empty($CFG->early_install_lang)) {

if (empty($CFG->langcacheroot)) {
$langcacheroot = $CFG->dataroot . '/cache/lang';
$langcacheroot = $CFG->cachedir . '/lang';
} else {
$langcacheroot = $CFG->langcacheroot;
}
Expand All @@ -5697,7 +5697,7 @@ function get_string_manager($forcereload=false) {
}

if (empty($CFG->langmenucachefile)) {
$langmenucache = $CFG->dataroot . '/cache/languages';
$langmenucache = $CFG->cachedir . '/languages';
} else {
$langmenucache = $CFG->langmenucachefile;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/outputlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function theme_reset_all_caches() {
require_once("$CFG->libdir/filelib.php");

set_config('themerev', empty($CFG->themerev) ? 1 : $CFG->themerev+1);
fulldelete("$CFG->dataroot/cache/theme");
fulldelete("$CFG->cachedir/theme");
}

/**
Expand Down Expand Up @@ -613,7 +613,7 @@ public function css_urls(moodle_page $page) {
if (!defined('THEME_DESIGNER_CACHE_LIFETIME')) {
define('THEME_DESIGNER_CACHE_LIFETIME', 4); // this can be also set in config.php
}
$candidatesheet = "$CFG->dataroot/cache/theme/$this->name/designer.ser";
$candidatesheet = "$CFG->cachedir/theme/$this->name/designer.ser";
if (!file_exists($candidatesheet)) {
$css = $this->css_content();
check_dir_exists(dirname($candidatesheet));
Expand Down
2 changes: 1 addition & 1 deletion lib/outputrequirementslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,6 @@ function js_reset_all_caches() {
require_once("$CFG->libdir/filelib.php");

set_config('jsrev', empty($CFG->jsrev) ? 1 : $CFG->jsrev+1);
fulldelete("$CFG->dataroot/cache/js");
fulldelete("$CFG->cachedir/js");
}

2 changes: 1 addition & 1 deletion lib/pdflib.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
define('K_PATH_FONTS', K_PATH_MAIN . 'fonts/');

/** cache directory for temporary files (full path) */
define('K_PATH_CACHE', $CFG->dataroot . '/cache/');
define('K_PATH_CACHE', $CFG->cachedir . '/');

/** images directory */
define('K_PATH_IMAGES', $CFG->dirroot . '/');
Expand Down
4 changes: 2 additions & 2 deletions lib/rsslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function rss_print_link($contextid, $userid, $componentname, $id, $tooltiptext='
function rss_delete_file($componentname, $instance) {
global $CFG;

$dirpath = "$CFG->dataroot/cache/rss/$componentname";
$dirpath = "$CFG->cachedir/rss/$componentname";
if (is_dir($dirpath)) {
$dh = opendir($dirpath);
while (false !== ($filename = readdir($dh))) {
Expand Down Expand Up @@ -170,7 +170,7 @@ function rss_save_file($componentname, $filename, $contents, $expandfilename=tru

function rss_get_file_full_name($componentname, $filename) {
global $CFG;
return "$CFG->dataroot/cache/rss/$componentname/$filename.xml";
return "$CFG->cachedir/rss/$componentname/$filename.xml";
}

function rss_get_file_name($instance, $sql) {
Expand Down
2 changes: 1 addition & 1 deletion lib/simplepie/moodle_simplepie.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function __construct($feedurl = null) {
private static function get_cache_directory() {
global $CFG;

return $CFG->dataroot.'/cache/simplepie/';
return $CFG->cachedir.'/simplepie/';
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/weblib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,7 @@ function reset_text_filters_cache() {
global $CFG, $DB;

$DB->delete_records('cache_text');
$purifdir = $CFG->dataroot.'/cache/htmlpurifier';
$purifdir = $CFG->cachedir.'/htmlpurifier';
remove_dir($purifdir, true);
}

Expand Down Expand Up @@ -1514,7 +1514,7 @@ function purify_html($text, $options = array()) {
if (empty($purifiers[$type])) {

// make sure the serializer dir exists, it should be fine if it disappears later during cache reset
$cachedir = $CFG->dataroot.'/cache/htmlpurifier';
$cachedir = $CFG->cachedir.'/htmlpurifier';
check_dir_exists($cachedir);

require_once $CFG->libdir.'/htmlpurifier/HTMLPurifier.safe-includes.php';
Expand Down
2 changes: 1 addition & 1 deletion theme/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
image_not_found();
}

$candidatelocation = "$CFG->dataroot/cache/theme/$themename/pix/$component";
$candidatelocation = "$CFG->cachedir/theme/$themename/pix/$component";

if ($rev > -1) {
if (file_exists("$candidatelocation/$image.error")) {
Expand Down
2 changes: 1 addition & 1 deletion theme/javascript.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
die('Theme was not found, sorry.');
}

$candidate = "$CFG->dataroot/cache/theme/$themename/javascript_$type.js";
$candidate = "$CFG->cachedir/theme/$themename/javascript_$type.js";

if ($rev > -1 and file_exists($candidate)) {
if (!empty($_SERVER['HTTP_IF_NONE_MATCH']) || !empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
Expand Down
6 changes: 3 additions & 3 deletions theme/styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
send_ie_css($themename, $rev);
}

$candidatesheet = "$CFG->dataroot/cache/theme/$themename/css/$type.css";
$candidatesheet = "$CFG->cachedir/theme/$themename/css/$type.css";

if (file_exists($candidatesheet)) {
if (!empty($_SERVER['HTTP_IF_NONE_MATCH']) || !empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
Expand Down Expand Up @@ -97,11 +97,11 @@
$cssfiles[] = $val;
}
}
$cssfile = "$CFG->dataroot/cache/theme/$themename/css/$key.css";
$cssfile = "$CFG->cachedir/theme/$themename/css/$key.css";
store_css($theme, $cssfile, $cssfiles);
$allfiles = array_merge($allfiles, $cssfiles);
}
$cssfile = "$CFG->dataroot/cache/theme/$themename/css/all.css";
$cssfile = "$CFG->cachedir/theme/$themename/css/all.css";
store_css($theme, $cssfile, $allfiles);
}
send_cached_css($candidatesheet, $rev);
Expand Down
2 changes: 1 addition & 1 deletion theme/styles_debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

// no gzip compression when debugging

$candidatesheet = "$CFG->dataroot/cache/theme/$themename/designer.ser";
$candidatesheet = "$CFG->cachedir/theme/$themename/designer.ser";

if (!file_exists($candidatesheet)) {
css_not_found();
Expand Down

0 comments on commit 365bec4

Please sign in to comment.