From 1194ce95589094c453ba7c17879130c1f957cf8c Mon Sep 17 00:00:00 2001 From: Jaime Perez Crespo <jaime.perez@uninett.no> Date: Tue, 20 Jan 2015 16:33:28 +0100 Subject: [PATCH] Remove deprecated SimpleSAML_MemcacheStore class. This closes #152. --- config-templates/config.php | 6 +- lib/SimpleSAML/MemcacheStore.php | 90 -------------------------- lib/SimpleSAML/SessionHandlerStore.php | 22 +------ 3 files changed, 4 insertions(+), 114 deletions(-) delete mode 100644 lib/SimpleSAML/MemcacheStore.php diff --git a/config-templates/config.php b/config-templates/config.php index acc009e59..e11704b88 100644 --- a/config-templates/config.php +++ b/config-templates/config.php @@ -623,8 +623,8 @@ $config = array( /* - * Configuration for the MemcacheStore class. This allows you to store - * multiple redudant copies of sessions on different memcache servers. + * Configuration for the 'memcache' session store. This allows you to store + * multiple redundant copies of sessions on different memcache servers. * * 'memcache_store.servers' is an array of server groups. Every data * item will be mirrored in every server group. @@ -645,7 +645,7 @@ $config = array( * - 'timeout': The timeout for this server. By default, the timeout * is 3 seconds. * - * Example of redudant configuration with load balancing: + * Example of redundant configuration with load balancing: * This configuration makes it possible to lose both servers in the * a-group or both servers in the b-group without losing any sessions. * Note that sessions will be lost if one server is lost from both the diff --git a/lib/SimpleSAML/MemcacheStore.php b/lib/SimpleSAML/MemcacheStore.php deleted file mode 100644 index 55509295b..000000000 --- a/lib/SimpleSAML/MemcacheStore.php +++ /dev/null @@ -1,90 +0,0 @@ -<?php - -/** - * This class provides a class with behaviour similar to the $_SESSION variable. - * Data is automatically saved on exit. - * - * Care should be taken when using this class to store objects. It will not detect changes to objects - * automatically. Instead, a call to set(...) should be done to notify this class of changes. - * - * @author Olav Morken, UNINETT AS. - * @package simpleSAMLphp - * @deprecated This class will be removed in version 1.8 of simpleSAMLphp. - */ -class SimpleSAML_MemcacheStore { - - - /** - * This variable contains an array with all key-value pairs stored - * in this object. - */ - private $data = NULL; - - - /** - * This function is used to find an existing storage object. It will return NULL if no storage object - * with the given id is found. - * - * @param $id The id of the storage object we are looking for. A id consists of lowercase - * alphanumeric characters. - * @return The corresponding MemcacheStorage object if the data is found or NULL if it isn't found. - */ - public static function find($id) { - assert(self::isValidID($id)); - - $serializedData = SimpleSAML_Memcache::get($id); - if($serializedData === NULL) { - return NULL; - } - - $data = unserialize($serializedData); - - if(!($data instanceof self)) { - SimpleSAML_Logger::warning('Retrieved key from memcache did not contain a MemcacheStore object.'); - return NULL; - } - - return $data; - } - - - /** - * This function retrieves the specified key from this storage object. - * - * @param $key The key we should retrieve the value of. - * @return The value of the specified key, or NULL of the key wasn't found. - */ - public function get($key) { - if(!array_key_exists($key, $this->data)) { - return NULL; - } - - return $this->data[$key]; - } - - - /** - * This function determines whether the argument is a valid id. - * A valid id is a string containing lowercase alphanumeric - * characters. - * - * @param $id The id we should validate. - * @return TRUE if the id is valid, FALSE otherwise. - */ - private static function isValidID($id) { - if(!is_string($id)) { - return FALSE; - } - - if(strlen($id) < 1) { - return FALSE; - } - - if(preg_match('/[^0-9a-z]/', $id)) { - return FALSE; - } - - return TRUE; - } - -} diff --git a/lib/SimpleSAML/SessionHandlerStore.php b/lib/SimpleSAML/SessionHandlerStore.php index 5b15cf8f4..02ccf6c45 100644 --- a/lib/SimpleSAML/SessionHandlerStore.php +++ b/lib/SimpleSAML/SessionHandlerStore.php @@ -41,27 +41,7 @@ class SimpleSAML_SessionHandlerStore extends SimpleSAML_SessionHandlerCookie { return $session; } - if (!($this->store instanceof SimpleSAML_Store_Memcache)) { - return NULL; - } - - /* For backwards compatibility, check the MemcacheStore object. */ - $store = SimpleSAML_MemcacheStore::find($sessionId); - if ($store === NULL) { - return NULL; - } - - $session = $store->get('SimpleSAMLphp_SESSION'); - if ($session === NULL) { - return NULL; - } - - assert('is_string($session)'); - - $session = unserialize($session); - assert('$session instanceof SimpleSAML_Session'); - - return $session; + return NULL; } -- GitLab