#8960: more than one list ilter breaks contact search
authorPhilipp Schüle <p.schuele@metaways.de>
Thu, 26 Sep 2013 12:35:54 +0000 (14:35 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 26 Sep 2013 15:13:26 +0000 (17:13 +0200)
- added unique correlation name for each filter

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

Change-Id: I959003d121fa702173601cd8573d9de64df6a967
Reviewed-on: http://gerrit.tine20.com/customers/144
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
Tested-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Addressbook/Model/ListMemberFilter.php

index 96d328b..6f8ab4d 100644 (file)
@@ -33,12 +33,13 @@ class Addressbook_Model_ListMemberFilter extends Tinebase_Model_Filter_Abstract
      */
     public function appendFilterSql($_select, $_backend)
     {
+        $correlationName = Tinebase_Record_Abstract::generateUID(30);
         $db = $_backend->getAdapter();
         $_select->joinLeft(
-            /* table  */ array('members' => $db->table_prefix . 'addressbook_list_members'), 
-            /* on     */ $db->quoteIdentifier('members.contact_id') . ' = ' . $db->quoteIdentifier('addressbook.id'),
+            /* table  */ array($correlationName => $db->table_prefix . 'addressbook_list_members'), 
+            /* on     */ $db->quoteIdentifier($correlationName . '.contact_id') . ' = ' . $db->quoteIdentifier('addressbook.id'),
             /* select */ array()
         );
-        $_select->where($db->quoteIdentifier('members.list_id') . ' IN (?)', (array) $this->_value);
+        $_select->where($db->quoteIdentifier($correlationName . '.list_id') . ' IN (?)', (array) $this->_value);
     }
 }