0012150: sync groups: primary group deleting fails
authorPhilipp Schüle <p.schuele@metaways.de>
Thu, 1 Sep 2016 12:31:18 +0000 (14:31 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Fri, 2 Sep 2016 11:16:39 +0000 (13:16 +0200)
* always update users primary groups before deleting

https://forge.tine20.org/view.php?id=12150

Change-Id: I5a6facb7cbbe17f94a9cbb71fd7d86589e723591
Reviewed-on: http://gerrit.tine20.com/customers/3505
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Tinebase/Group/Sql.php

index f3adb2b..b6fdafe 100644 (file)
@@ -527,16 +527,14 @@ class Tinebase_Group_Sql extends Tinebase_Group_Abstract
         
         try {
             $transactionId = Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
-            
-            $this->_updatePrimaryGroupsOfUsers($groupIds);
-            
+
             $this->deleteGroupsInSqlBackend($groupIds);
             if ($this instanceof Tinebase_Group_Interface_SyncAble) {
                 $this->deleteGroupsInSyncBackend($groupIds);
             }
-            
+
             Tinebase_TransactionManager::getInstance()->commitTransaction($transactionId);
-            
+
         } catch (Exception $e) {
             Tinebase_TransactionManager::getInstance()->rollBack();
             Tinebase_Exception::log($e);
@@ -572,6 +570,8 @@ class Tinebase_Group_Sql extends Tinebase_Group_Abstract
      */
     public function deleteGroupsInSqlBackend($groupIds)
     {
+        $this->_updatePrimaryGroupsOfUsers($groupIds);
+
         $where = $this->_db->quoteInto($this->_db->quoteIdentifier('group_id') . ' IN (?)', (array) $groupIds);
         $this->groupMembersTable->delete($where);
         $where = $this->_db->quoteInto($this->_db->quoteIdentifier('id') . ' IN (?)', (array) $groupIds);