Exdate delete does not update seq of base event
authorCornelius Weiß <mail@corneliusweiss.de>
Fri, 23 Jan 2015 09:43:08 +0000 (10:43 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Tue, 27 Jan 2015 09:06:50 +0000 (10:06 +0100)
Change-Id: I2cffee8d26937dd5f2d002b6bf10ba3c981fcbaa
Reviewed-on: http://gerrit.tine20.com/customers/1558
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/ActiveSync/Controller/CalendarTests.php
tine20/Calendar/Controller/Event.php
tine20/Calendar/Controller/MSEventFacade.php

index 418d0d0..519fd75 100644 (file)
@@ -779,7 +779,28 @@ Zeile 3</AirSyncBase:Data>
         $this->assertEquals($event->seq + 1, $baseEventAfterExdateUpdate->seq, 'base sequence should be updated');
         $this->assertEquals($container->content_seq + 2, $containerAfterExdateUpdate->content_seq, 'container sequence should be updated');
     }
-    
+
+    /**
+     * testDeleteExdate
+     *
+     * @see : Exdate delete does not update seq of base event
+     */
+    public function testDeleteExdate()
+    {
+        list($serverId, $syncrotonEvent) = $this->testCreateEntry();
+
+        $event = Calendar_Controller_Event::getInstance()->get($serverId);
+        $container = Tinebase_Container::getInstance()->get($event->container_id);
+
+        $exception = Calendar_Controller_Event::getInstance()->getRecurExceptions($event)->getFirstRecord();
+        Calendar_Controller_Event::getInstance()->delete($exception);
+
+        $baseEventAfterExdateDelete = Calendar_Controller_Event::getInstance()->get($serverId);
+        $containerAfterExdateDelete = Tinebase_Container::getInstance()->get($event->container_id);
+        $this->assertGreaterThan($event->seq, $baseEventAfterExdateDelete->seq, 'base sequence should be updated');
+        $this->assertGreaterThan($container->content_seq, $containerAfterExdateDelete->content_seq, 'container sequence should be updated');
+    }
+
     public function testRecurEventExceptionFilters($syncrotonFolder = null)
     {
         if ($syncrotonFolder === null) {
index 9504830..eac0fa2 100644 (file)
@@ -764,6 +764,17 @@ class Calendar_Controller_Event extends Tinebase_Controller_Record_Abstract impl
                     // NOTE delete needs to update sequence otherwise iTIP based protocolls ignore the delete
                     $record->status = Calendar_Model_Event::STATUS_CANCELED;
                     $this->_touch($record);
+                    if ($record->isRecurException()) {
+                        try {
+                            $baseEvent = $this->getRecurBaseEvent($record);
+                            $this->_touch($baseEvent);
+                        } catch (Tinebase_Exception_NotFound $tnfe) {
+                            // base Event might be gone already
+                            if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__
+                                . " BaseEvent of exdate {$record->uid} to delete not found ");
+
+                        }
+                    }
                     parent::delete($record);
                 }
                 
@@ -796,7 +807,10 @@ class Calendar_Controller_Event extends Tinebase_Controller_Record_Abstract impl
     
     /**
      * delete range of events starting with given recur exception
-     * 
+     *
+     * NOTE: if exdate is persistent, it will not be deleted by this function
+     *       but by the original call of delete
+     *
      * @param Calendar_Model_Event $exdate
      * @param string $range
      */
index 888bd24..2122da0 100644 (file)
@@ -539,7 +539,7 @@ class Calendar_Controller_MSEventFacade implements Tinebase_Controller_Record_In
                     if ($exceptionId) {
                         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__
                             . ' Found exdate to be deleted (id: ' . $exceptionId . ')');
-                        $ids[] = $exceptionId;
+                        array_unshift($ids, $exceptionId);
                     }
                 }
             }