Merge branch '2013.10' into 2014.11
authorPhilipp Schüle <p.schuele@metaways.de>
Wed, 7 Jan 2015 16:48:58 +0000 (17:48 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 7 Jan 2015 16:48:58 +0000 (17:48 +0100)
Conflicts:
tine20/Tinebase/Group/Sql.php

Change-Id: I42c8f9924e73ae522c9a8a7e452d75f79debf46f

1  2 
tine20/Tinebase/Group/Sql.php

@@@ -83,24 -92,30 +92,30 @@@ class Tinebase_Group_Sql extends Tineba
      {
          $accountId = Tinebase_Model_User::convertUserIdToInt($_accountId);
          
-         $cacheId = Tinebase_Helper::convertCacheId('groupMemberships' . $accountId);
+         $classCacheId = $accountId;
+         
+         if (isset($this->_classCache[__FUNCTION__][$classCacheId])) {
+             return $this->_classCache[__FUNCTION__][$classCacheId];
+         }
+         
 -        $cacheId     = convertCacheId(__FUNCTION__ . $classCacheId);
++        $cacheId     = Tinebase_Helper::convertCacheId(__FUNCTION__ . $classCacheId);
          $memberships = Tinebase_Core::getCache()->load($cacheId);
+         
          if (! $memberships) {
-             $memberships = array();
-             $colName = $this->groupsTable->getAdapter()->quoteIdentifier('account_id');
-             $select = $this->groupMembersTable->select();
-             $select->where($colName . ' = ?', $accountId);
+             $select = $this->_db->select()
+                 ->distinct()
+                 ->from(array('group_members' => SQL_TABLE_PREFIX . 'group_members'), array('group_id'))
+                 ->where($this->_db->quoteIdentifier('account_id') . ' = ?', $accountId);
              
-             $rows = $this->groupMembersTable->fetchAll($select);
+             $stmt = $this->_db->query($select);
+             
+             $memberships = $stmt->fetchAll(Zend_Db::FETCH_COLUMN);
              
-             foreach($rows as $membership) {
-                 $memberships[] = $membership->group_id;
-             }
              Tinebase_Core::getCache()->save($memberships, $cacheId);
          }
+         
+         $this->_classCache[__FUNCTION__][$classCacheId] = $memberships;
+         
          return $memberships;
      }
      
      {
          $groupId = Tinebase_Model_Group::convertGroupIdToInt($_groupId);
          
-         $cacheId = Tinebase_Helper::convertCacheId('groupMembers' . $groupId);
 -        $cacheId = convertCacheId(__FUNCTION__ . $groupId);
++        $cacheId = Tinebase_Helper::convertCacheId(__FUNCTION__ . $groupId);
          $members = Tinebase_Core::getCache()->load($cacheId);
  
          if (! $members) {
       */
      protected function _clearCache($cacheIds = array())
      {
+         $cache = Tinebase_Core::getCache();
+         
          foreach ($cacheIds as $type => $id) {
 -            $cacheId = convertCacheId($type . $id);
 +            $cacheId = Tinebase_Helper::convertCacheId($type . $id);
-             Tinebase_Core::getCache()->remove($cacheId);
+             $cache->remove($cacheId);
          }
+         
+         $this->resetClassCache();
      }
      
      /**