0011290: tag filter returns wrong counts
authorPaul Mehrer <p.mehrer@metaways.de>
Thu, 6 Aug 2015 15:34:02 +0000 (17:34 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 2 Sep 2015 12:22:42 +0000 (14:22 +0200)
* fixes result count bug for TagFilter

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

Change-Id: I494fb9f332ff25dad66fe238fe6b3049ec7d2c9f
Reviewed-on: http://gerrit.tine20.com/customers/2102
Tested-by: sstamer <s.stamer@metaways.de>
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Tinebase/TagsTest.php
tine20/Tinebase/Model/Filter/Tag.php

index 9dbfe82..e20ca72 100644 (file)
@@ -273,6 +273,8 @@ class Tinebase_TagsTest extends TestCase
             array('field' => 'id', 'operator' => 'in', 'value' => array_slice($contactIds, 0, 3))
         ));
         $sharedTag1 = Tinebase_Tags::getInstance()->attachTagToMultipleRecords($contactFilter, $sharedTag1);
+        $this->assertEquals(3, $sharedTag1->occurrence);
+
         $contactFilter = new Addressbook_Model_ContactFilter(array(
             array('field' => 'id', 'operator' => 'in', 'value' => array_slice($contactIds, 3, 3))
         ));
index 9a62769..f75896e 100644 (file)
@@ -43,6 +43,7 @@ class Tinebase_Model_Filter_Tag extends Tinebase_Model_Filter_Abstract
      * set options 
      *
      * @param  array $_options
+     * @throws Tinebase_Exception_InvalidArgument
      */
     protected function _setOptions(array $_options)
     {
@@ -91,6 +92,7 @@ class Tinebase_Model_Filter_Tag extends Tinebase_Model_Filter_Abstract
         /* select */  array());
         
         $_select->where($db->quoteIdentifier("{$correlationName}.tag_id") .  $this->_opSqlMap[$this->_operator]['sqlop']);
+        $_select->group($this->_options['idProperty']);
     }
     
     /**