0010610: yearly event is not shown in week view
authorPhilipp Schüle <p.schuele@metaways.de>
Mon, 29 Dec 2014 12:25:34 +0000 (13:25 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Tue, 30 Dec 2014 12:41:14 +0000 (13:41 +0100)
* Skipping performance optimization (removal of base events with
non-matching rrule) because we can't handle year boundaries yet

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

Change-Id: I2e35bf9fdc541264da6c8a5533078e4fd510ce7d
Reviewed-on: http://gerrit.tine20.com/customers/1489
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Calendar/JsonTests.php
tine20/Calendar/Backend/Sql.php

index 53e983f..359d660 100644 (file)
@@ -391,6 +391,37 @@ class Calendar_JsonTests extends Calendar_TestCase
 
         return $updatedEventData;
     }
+
+    /**
+     * testCreateRecurEventYearly
+     * 
+     * @see 0010610: yearly event is not shown in week view
+     */
+    public function testCreateRecurEventYearly()
+    {
+        $eventData = $this->_getEvent()->toArray();
+        $eventData['is_all_day_event'] = true;
+        $eventData['dtstart'] = '2015-01-04 00:00:00';
+        $eventData['dtend'] = '2015-01-04 23:59:59';
+        $eventData['rrule'] = array(
+            'freq'       => 'YEARLY',
+            'interval'   => 1,
+            'bymonthday' => 4,
+            'bymonth'    => 1,
+        );
+        
+        $updatedEventData = $this->_uit->saveEvent($eventData);
+        $this->assertTrue(is_array($updatedEventData['rrule']));
+        
+        $filter = array(
+            array('field' => 'container_id', 'operator' => 'equals', 'value' => $eventData['container_id']),
+            array('field' => 'period', 'operator' => 'within', 'value' =>
+                array("from" => '2014-12-29 00:00:00', "until" => '2015-01-05 00:00:00')
+            )
+        );
+        $searchResultData = $this->_uit->searchEvents($filter, array());
+        $this->assertEquals(1, $searchResultData['totalcount'], 'event not found');
+    }
     
     /**
      * testCreateRecurEventWithRruleUntil
index eaa770f..f16d863 100644 (file)
@@ -267,9 +267,15 @@ class Calendar_Backend_Sql extends Tinebase_Backend_Sql_Abstract
         $gs->where($quotedRrule . ' NOT LIKE ?', 'FREQ=YEARLY%')
         ->orWhere($quotedRrule . ' IS NULL');
         
+        // TODO improve view detection to handle year boundaries, too
+        if ($fromMonth > $untilMonth) {
+            if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__
+                    . ' Skipping performance optimization because we can\'t handle year boundaries yet');
+            return;
+        }
         if ($fromMonth == $untilMonth && $untilDay-$fromDay <= 10) {
             // day|week view
-            for($day=$fromDay; $day<=$untilDay; $day++) {
+            for ($day=$fromDay; $day<=$untilDay; $day++) {
                 $gs->orWhere($quotedRrule . ' LIKE ?', "FREQ=YEARLY;INTERVAL=1;BYMONTH={$fromMonth};BYMONTHDAY={$day}%");
             }
         } else {
@@ -280,7 +286,9 @@ class Calendar_Backend_Sql extends Tinebase_Backend_Sql_Abstract
         }
         
         $gs->appendWhere(Zend_Db_Select::SQL_AND);
-        //            Tinebase_Core::getLogger()->ERR($select);
+        
+        if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__
+            . ' ' . $select);
     }
     
     /**