Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-36768 cache: Fixed regression in cache stores by reordering classes

  • Loading branch information...
commit b144e12feb2ab4295c838383e636e0fc701cbb93 1 parent 0aa6247
@samhemelryk samhemelryk authored
Showing with 109 additions and 109 deletions.
  1. +56 −56 cache/stores/session/lib.php
  2. +53 −53 cache/stores/static/lib.php
View
112 cache/stores/session/lib.php
@@ -29,6 +29,62 @@
defined('MOODLE_INTERNAL') || die();
/**
+ * The session data store class.
+ *
+ * @copyright 2012 Sam Hemelryk
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+abstract class session_data_store extends cache_store {
+
+ /**
+ * Used for the actual storage.
+ * @var array
+ */
+ private static $sessionstore = null;
+
+ /**
+ * Returns a static store by reference... REFERENCE SUPER IMPORTANT.
+ *
+ * @param string $id
+ * @return array
+ */
+ protected static function &register_store_id($id) {
+ if (is_null(self::$sessionstore)) {
+ global $SESSION;
+ if (!isset($SESSION->cachestore_session)) {
+ $SESSION->cachestore_session = array();
+ }
+ self::$sessionstore =& $SESSION->cachestore_session;
+ }
+ if (!array_key_exists($id, self::$sessionstore)) {
+ self::$sessionstore[$id] = array();
+ }
+ return self::$sessionstore[$id];
+ }
+
+ /**
+ * Flushes the data belong to the given store id.
+ * @param string $id
+ */
+ protected static function flush_store_by_id($id) {
+ unset(self::$sessionstore[$id]);
+ self::$sessionstore[$id] = array();
+ }
+
+ /**
+ * Flushes the store of all data.
+ */
+ protected static function flush_store() {
+ $ids = array_keys(self::$sessionstore);
+ unset(self::$sessionstore);
+ self::$sessionstore = array();
+ foreach ($ids as $id) {
+ self::$sessionstore[$id] = array();
+ }
+ }
+}
+
+/**
* The Session store class.
*
* @copyright 2012 Sam Hemelryk
@@ -343,60 +399,4 @@ public static function initialise_test_instance(cache_definition $definition) {
public function my_name() {
return $this->name;
}
-}
-
-/**
- * The session data store class.
- *
- * @copyright 2012 Sam Hemelryk
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-abstract class session_data_store extends cache_store {
-
- /**
- * Used for the actual storage.
- * @var array
- */
- private static $sessionstore = null;
-
- /**
- * Returns a static store by reference... REFERENCE SUPER IMPORTANT.
- *
- * @param string $id
- * @return array
- */
- protected static function &register_store_id($id) {
- if (is_null(self::$sessionstore)) {
- global $SESSION;
- if (!isset($SESSION->cachestore_session)) {
- $SESSION->cachestore_session = array();
- }
- self::$sessionstore =& $SESSION->cachestore_session;
- }
- if (!array_key_exists($id, self::$sessionstore)) {
- self::$sessionstore[$id] = array();
- }
- return self::$sessionstore[$id];
- }
-
- /**
- * Flushes the data belong to the given store id.
- * @param string $id
- */
- protected static function flush_store_by_id($id) {
- unset(self::$sessionstore[$id]);
- self::$sessionstore[$id] = array();
- }
-
- /**
- * Flushes the store of all data.
- */
- protected static function flush_store() {
- $ids = array_keys(self::$sessionstore);
- unset(self::$sessionstore);
- self::$sessionstore = array();
- foreach ($ids as $id) {
- self::$sessionstore[$id] = array();
- }
- }
}
View
106 cache/stores/static/lib.php
@@ -29,6 +29,58 @@
defined('MOODLE_INTERNAL') || die();
/**
+ * The static data store class
+ *
+ * @copyright 2012 Sam Hemelryk
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+abstract class static_data_store extends cache_store {
+
+ /**
+ * An array for storage.
+ * @var array
+ */
+ private static $staticstore = array();
+
+ /**
+ * Returns a static store by reference... REFERENCE SUPER IMPORTANT.
+ *
+ * @param string $id
+ * @return array
+ */
+ protected static function &register_store_id($id) {
+ if (!array_key_exists($id, self::$staticstore)) {
+ self::$staticstore[$id] = array();
+ }
+ return self::$staticstore[$id];
+ }
+
+ /**
+ * Flushes the store of all values for belonging to the store with the given id.
+ * @param string $id
+ */
+ protected static function flush_store_by_id($id) {
+ unset(self::$staticstore[$id]);
+ self::$staticstore[$id] = array();
+ }
+
+ /**
+ * Flushes all of the values from all stores.
+ *
+ * @copyright 2012 Sam Hemelryk
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+ protected static function flush_store() {
+ $ids = array_keys(self::$staticstore);
+ unset(self::$staticstore);
+ self::$staticstore = array();
+ foreach ($ids as $id) {
+ self::$staticstore[$id] = array();
+ }
+ }
+}
+
+/**
* The static store class.
*
* @copyright 2012 Sam Hemelryk
@@ -343,56 +395,4 @@ public static function initialise_test_instance(cache_definition $definition) {
public function my_name() {
return $this->name;
}
-}
-
-/**
- * The static data store class
- *
- * @copyright 2012 Sam Hemelryk
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-abstract class static_data_store extends cache_store {
-
- /**
- * An array for storage.
- * @var array
- */
- private static $staticstore = array();
-
- /**
- * Returns a static store by reference... REFERENCE SUPER IMPORTANT.
- *
- * @param string $id
- * @return array
- */
- protected static function &register_store_id($id) {
- if (!array_key_exists($id, self::$staticstore)) {
- self::$staticstore[$id] = array();
- }
- return self::$staticstore[$id];
- }
-
- /**
- * Flushes the store of all values for belonging to the store with the given id.
- * @param string $id
- */
- protected static function flush_store_by_id($id) {
- unset(self::$staticstore[$id]);
- self::$staticstore[$id] = array();
- }
-
- /**
- * Flushes all of the values from all stores.
- *
- * @copyright 2012 Sam Hemelryk
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
- protected static function flush_store() {
- $ids = array_keys(self::$staticstore);
- unset(self::$staticstore);
- self::$staticstore = array();
- foreach ($ids as $id) {
- self::$staticstore[$id] = array();
- }
- }
-}
+}
Please sign in to comment.
Something went wrong with that request. Please try again.