skips already deleted exdates during event update
authorPhilipp Schüle <p.schuele@metaways.de>
Wed, 4 Feb 2015 16:56:49 +0000 (17:56 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 18 Feb 2015 16:35:28 +0000 (17:35 +0100)
* adds a new param skipMissing to
Tinebase_Record_RecordSet::setByIndices()

Change-Id: I6f986395011a91deb73e898ed62f213eedb12bf9
Reviewed-on: http://gerrit.tine20.com/customers/1609
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Calendar/Controller/MSEventFacade.php
tine20/Tinebase/Record/RecordSet.php

index 2122da0..0b8e489 100644 (file)
@@ -941,14 +941,7 @@ class Calendar_Controller_MSEventFacade implements Tinebase_Controller_Record_In
         
         // get ids for toUpdate
         $idxIdMap = $this->_filterEventsByDTStarts($_currentPersistentExceptions, $toUpdateDtSTart)->getId();
-        try {
-            $migration['toUpdate']->setByIndices('id', $idxIdMap);
-        } catch (Tinebase_Exception_Record_NotDefined $ternd) {
-            // some debugging for 0008182: event with lots of exceptions breaks calendar sync
-            if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . print_r($idxIdMap, TRUE));
-            if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . print_r($migration['toUpdate']->toArray(), TRUE));
-            throw $ternd;
-        }
+        $migration['toUpdate']->setByIndices('id', $idxIdMap, /* $skipMissing = */ true);
         
         // filter exceptions marked as don't touch 
         foreach ($migration['toUpdate'] as $toUpdate) {
index b423d05..4e6d9c5 100644 (file)
@@ -278,13 +278,20 @@ class Tinebase_Record_RecordSet implements IteratorAggregate, Countable, ArrayAc
      *
      * @param string $_name property name
      * @param array  $_values index => property value
+     * @param boolean $skipMissing
      * @throws Tinebase_Exception_Record_NotDefined
      */
-    public function setByIndices($_name, array $_values)
+    public function setByIndices($_name, array $_values, $skipMissing = false)
     {
         foreach ($_values as $index => $value) {
             if (! (isset($this->_listOfRecords[$index]) || array_key_exists($index, $this->_listOfRecords))) {
-                throw new Tinebase_Exception_Record_NotDefined('Could not find record with index ' . $index);
+                if ($skipMissing) {
+                    if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ 
+                        . ' Skip missing record ' . $index . ' => ' . $value . ' property: ' . $_name);
+                    continue;
+                } else {
+                    throw new Tinebase_Exception_Record_NotDefined('Could not find record with index ' . $index);
+                }
             }
             $this->_listOfRecords[$index]->$_name = $value;
         }