Permalink
Browse files

MDL-25290 cache: Fixed up issue with unit test blowing away cachedir

  • Loading branch information...
Sam Hemelryk
Sam Hemelryk committed Sep 10, 2012
1 parent e3b77f9 commit 52642d0d244c1c2273c4b2fe0a819ad925551aa4
Showing with 10 additions and 1 deletion.
  1. +0 −1 cache/tests/cache_test.php
  2. +4 −0 lib/moodlelib.php
  3. +3 −0 lib/phpunit/classes/util.php
  4. +3 −0 lib/sessionlib.php
@@ -49,7 +49,6 @@ class cache_phpunit_tests extends advanced_testcase {
public function setUp() {
parent::setUp();
cache_factory::reset();
- cache_lock::reset();
cache_config_phpunittest::create_default_configuration();
}
View
@@ -1487,6 +1487,10 @@ function get_users_from_config($value, $capability, $includeadmins = true) {
/**
* 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() {
@@ -533,6 +533,9 @@ public static function reset_dataroot() {
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_lock::reset();
+ cache_factory::reset();
}
/**
View
@@ -953,6 +953,9 @@ function session_gc() {
function sesskey() {
// note: do not use $USER because it may not be initialised yet
if (empty($_SESSION['USER']->sesskey)) {
+ if (!isset($_SESSION['USER'])) {
+ $_SESSION['USER'] = new stdClass;
+ }
$_SESSION['USER']->sesskey = random_string(10);
}

0 comments on commit 52642d0

Please sign in to comment.