MDL-76745 cache: Implement cache_loader_with_locking in cache_disabled

If a plugin attempts to do something that would lock coursemodinfo cache
during install (such as creating a course module), this currently fails
as check_lock_state is not implemented in cache_disabled. Adding the
cache_loader_with_locking interface ensures that all lock methods are
implemented.
This commit is contained in:
Mark Johnson
2023-06-01 15:03:01 +01:00
parent 4ed782dd03
commit 09cf1b8818
2 changed files with 25 additions and 6 deletions
+9
View File
@@ -1426,6 +1426,15 @@ class cache_test extends \advanced_testcase {
$this->assertFalse($cache->set_versioned('v', 1, 'data'));
$this->assertFalse($cache->delete('test'));
$this->assertTrue($cache->purge());
// Checking a lock should always report that we have one.
// Acquiring or releasing a lock should always report success.
$this->assertTrue($cache->check_lock_state('test'));
$this->assertTrue($cache->acquire_lock('test'));
$this->assertTrue($cache->acquire_lock('test'));
$this->assertTrue($cache->check_lock_state('test'));
$this->assertTrue($cache->release_lock('test'));
$this->assertTrue($cache->release_lock('test'));
$this->assertTrue($cache->check_lock_state('test'));
// Test a session cache.
$cache = cache::make_from_params(cache_store::MODE_SESSION, 'phpunit', 'disable');