improve cred cache session persistence
authorPhilipp Schüle <p.schuele@metaways.de>
Thu, 23 May 2013 14:44:12 +0000 (16:44 +0200)
committerCornelius Weiss <c.weiss@metaways.de>
Thu, 23 May 2013 15:23:14 +0000 (17:23 +0200)
Change-Id: Iab8beefdaaae1ff14f89a343660f29436b1ff6f0
Reviewed-on: http://gerrit.tine20.com/customers/103
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Cornelius Weiss <c.weiss@metaways.de>
tine20/Tinebase/Auth/CredentialCache.php
tine20/Tinebase/Backend/Sql/Abstract.php
tine20/Tinebase/Model/CredentialCache.php

index 069b131..a276fd0 100644 (file)
@@ -151,7 +151,7 @@ class Tinebase_Auth_CredentialCache extends Tinebase_Backend_Sql_Abstract implem
     {
         $session = Tinebase_Core::getSession();
         if ($session && is_object($session)) {
-            $session->{self::SESSION_NAMESPACE}[$cache->getId()] = $cache;
+            $session->{self::SESSION_NAMESPACE}[$cache->getId()] = $cache->toArray();
         }
     }
     
@@ -160,9 +160,8 @@ class Tinebase_Auth_CredentialCache extends Tinebase_Backend_Sql_Abstract implem
      * -> needs to check if entry exists (some adapters can have static ids)
      * 
      * @param Tinebase_Model_CredentialCache $cache
-     * @param boolean $_saveInSession
      */
-    protected function _persistCache(Tinebase_Model_CredentialCache $cache, $_saveInSession = TRUE)
+    protected function _persistCache(Tinebase_Model_CredentialCache $cache)
     {
         try {
             $this->create($cache);
@@ -202,7 +201,7 @@ class Tinebase_Auth_CredentialCache extends Tinebase_Backend_Sql_Abstract implem
         $session = Tinebase_Core::getSession();
         $credentialSessionCache = ($session && is_object($session)) ? $session->{self::SESSION_NAMESPACE} : NULL;
         if (isset($credentialSessionCache) && isset($credentialSessionCache[$id])) {
-            $result = $credentialSessionCache[$id];
+            $result = new Tinebase_Model_CredentialCache($credentialSessionCache[$id]);
         } else {
             $result = $this->get($id);
             $this->_saveInSession($result);
index b33514a..499d250 100644 (file)
@@ -1009,7 +1009,7 @@ abstract class Tinebase_Backend_Sql_Abstract extends Tinebase_Backend_Abstract i
         $recordArray = array_intersect_key($recordArray, $this->_schema);
         
         $this->_prepareData($recordArray);
-                
+        
         $where  = array(
             $this->_db->quoteInto($this->_db->quoteIdentifier($identifier) . ' = ?', $id),
         );
@@ -1020,7 +1020,7 @@ abstract class Tinebase_Backend_Sql_Abstract extends Tinebase_Backend_Abstract i
         if ($_record->has('customfields')) {
             Tinebase_CustomField::getInstance()->saveRecordCustomFields($_record);
         }
-                
+        
         $this->_updateForeignKeys('update', $_record);
         
         $result = $this->get($id, true);
index b4225e8..6ef555e 100644 (file)
@@ -82,7 +82,7 @@ class Tinebase_Model_CredentialCache extends Tinebase_Record_Abstract
     {
         $array = parent::toArray($_recursive);
         
-        // remove highly sensitive data to prevent acidential apperance in logs etc.
+        // remove highly sensitive data to prevent accidental apperance in logs etc.
         unset($array['key']);
         unset($array['username']);
         unset($array['password']);