Skip to content
Snippets Groups Projects
Commit 860b451d authored by Tyler Antonio's avatar Tyler Antonio
Browse files

Generate the instance ID from the configuration itself instead of the...

Generate the instance ID from the configuration itself instead of the spl_object_id of the configuration class
parent e1ad2dbd
No related branches found
No related tags found
No related merge requests found
...@@ -48,7 +48,7 @@ class SimpleSAML_Database { ...@@ -48,7 +48,7 @@ class SimpleSAML_Database {
*/ */
public static function getInstance($altConfig = null) { public static function getInstance($altConfig = null) {
$config = ($altConfig)? $altConfig : SimpleSAML_Configuration::getInstance(); $config = ($altConfig)? $altConfig : SimpleSAML_Configuration::getInstance();
$instanceId = spl_object_hash($config); $instanceId = self::generateInstanceId($config);
/* Check if we already have initialized the session. */ /* Check if we already have initialized the session. */
if (isset(self::$instance[$instanceId])) { if (isset(self::$instance[$instanceId])) {
...@@ -85,6 +85,28 @@ class SimpleSAML_Database { ...@@ -85,6 +85,28 @@ class SimpleSAML_Database {
$this->tablePrefix = $config->getString('database.prefix', ''); $this->tablePrefix = $config->getString('database.prefix', '');
} }
/**
* Generate an Instance ID based on the database
* configuration.
*
* @param $config Configuration class
*
* @return string $instanceId
*/
private static function generateInstanceId($config){
$assembledConfig = array(
'master' => array(
'database.dsn' => $config->getValue('database.dsn'),
'database.username' => $config->getValue('database.username'),
'database.password' => $config->getValue('database.password'),
'database.persistent' => $config->getValue('database.persistent'),
),
'slaves' => $config->getValue('database.slaves'),
);
return sha1(serialize($assembledConfig));
}
/** /**
* This function connects to a dabase. * This function connects to a dabase.
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment