MDL-38565 cache: session caches now function as expected

This change is a large change to the way sessions are handled
within MUC after it was discovered that session did not function
as expected when any store other than the default session store
was being used.
As part of this change the session loader has been largely
customised in order to consolidate session data for the loader.
The unit tests have also being greatly increased to provide
better coverage for sessions.
This commit is contained in:
Sam Hemelryk
2013-04-19 10:11:48 +12:00
parent 3a8c4380c0
commit dbd2ea4e1f
14 changed files with 1014 additions and 29 deletions
+26 -1
View File
@@ -183,6 +183,13 @@ class cache_definition {
*/
protected $requirelockingwrite = false;
/**
* Gets set to true if this definition requires searchable stores.
* @since 2.4.4
* @var bool
*/
protected $requiresearchable = false;
/**
* Sets the maximum number of items that can exist in the cache.
* Please note this isn't a hard limit, and doesn't need to be enforced by the caches. They can choose to do so optionally.
@@ -307,6 +314,7 @@ class cache_definition {
$requiremultipleidentifiers = false;
$requirelockingread = false;
$requirelockingwrite = false;
$requiresearchable = ($mode === cache_store::MODE_SESSION) ? true : false;;
$maxsize = null;
$overrideclass = null;
$overrideclassfile = null;
@@ -342,6 +350,10 @@ class cache_definition {
}
$requirelocking = $requirelockingwrite || $requirelockingread;
if (array_key_exists('requiresearchable', $definition)) {
$requiresearchable = (bool)$definition['requiresearchable'];
}
if (array_key_exists('maxsize', $definition)) {
$maxsize = (int)$definition['maxsize'];
}
@@ -433,6 +445,7 @@ class cache_definition {
$cachedefinition->requirelocking = $requirelocking;
$cachedefinition->requirelockingread = $requirelockingread;
$cachedefinition->requirelockingwrite = $requirelockingwrite;
$cachedefinition->requiresearchable = $requiresearchable;
$cachedefinition->maxsize = $maxsize;
$cachedefinition->overrideclass = $overrideclass;
$cachedefinition->overrideclassfile = $overrideclassfile;
@@ -633,6 +646,15 @@ class cache_definition {
return $this->requirelockingwrite;
}
/**
* Returns true if this definition requires a searchable cache.
* @since 2.4.4
* @return bool
*/
public function require_searchable() {
return $this->requiresearchable;
}
/**
* Returns true if this definition has an associated data source.
* @return bool
@@ -686,6 +708,9 @@ class cache_definition {
if ($this->require_multiple_identifiers()) {
$requires += cache_store::SUPPORTS_MULTIPLE_IDENTIFIERS;
}
if ($this->require_searchable()) {
$requires += cache_store::IS_SEARCHABLE;
}
return $requires;
}
@@ -694,7 +719,7 @@ class cache_definition {
* @return bool
*/
public function should_be_persistent() {
return $this->persistent;
return $this->persistent || $this->mode === cache_store::MODE_SESSION;
}
/**