fix getContainerGrantsOfRecords for pgsql
authorPhilipp Schüle <p.schuele@metaways.de>
Mon, 7 Aug 2017 17:01:50 +0000 (19:01 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Tue, 8 Aug 2017 16:37:22 +0000 (18:37 +0200)
 ... array_keys converts to int in some cases which
 pgsql does not like ...

Change-Id: I3f1161a353c5c24b61c5cc4fda40c5bb2430c86d
Reviewed-on: http://gerrit.tine20.com/customers/5415
Tested-by: Jenkins CI (http://ci.tine20.com/) <tine20-jenkins@metaways.de>
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Tinebase/Container.php
tine20/Tinebase/Model/Container.php

index 6a6aa21..bb5b027 100644 (file)
@@ -1428,8 +1428,11 @@ class Tinebase_Container extends Tinebase_Backend_Sql_Abstract implements Tineba
     {
         $containerIds = array();
         foreach ($_records as $record) {
-            if (isset($record[$_containerProperty]) && !isset($containerIds[Tinebase_Model_Container::convertContainerId($record[$_containerProperty])])) {
-                $containerIds[Tinebase_Model_Container::convertContainerId($record[$_containerProperty])] = null;
+            if (isset($record[$_containerProperty])) {
+                $containerId = Tinebase_Model_Container::convertContainerId($record[$_containerProperty]);
+                if (! isset($containerIds[$containerId])) {
+                    $containerIds[$containerId] = $containerId;
+                }
             }
         }
         
@@ -1442,7 +1445,7 @@ class Tinebase_Container extends Tinebase_Backend_Sql_Abstract implements Tineba
             : $_accountId;
         
         $select = $this->_getSelect('*', TRUE)
-            ->where("{$this->_db->quoteIdentifier('container.id')} IN (?)", array_keys($containerIds))
+            ->where("{$this->_db->quoteIdentifier('container.id')} IN (?)", $containerIds)
             ->join(array(
                 /* table  */ 'container_acl' => SQL_TABLE_PREFIX . 'container_acl'), 
                 /* on     */ "{$this->_db->quoteIdentifier('container_acl.container_id')} = {$this->_db->quoteIdentifier('container.id')}",
index 469cc3c..e7463da 100644 (file)
@@ -156,14 +156,14 @@ class Tinebase_Model_Container extends Tinebase_Record_Abstract
     static public function convertContainerId($_containerId)
     {
         // null will be string casted to empty string
-        if($_containerId instanceof Tinebase_Model_Container) {
+        if ($_containerId instanceof Tinebase_Model_Container) {
             $id = (string)$_containerId->getId();
         } else {
             $id = (string)$_containerId;
         }
 
         // ctype_alnum returns false on empty string
-        if(false === ctype_alnum($id)) {
+        if (false === ctype_alnum($id)) {
             throw new Tinebase_Exception_InvalidArgument('No container id set.');
         }