diff(): date field in record could be DateTime without compare()
authorPhilipp Schüle <p.schuele@metaways.de>
Thu, 29 Jan 2015 14:25:05 +0000 (15:25 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Fri, 30 Jan 2015 11:37:15 +0000 (12:37 +0100)
-> convert to Tinebase_DateTime before comparing the dates

Change-Id: I4842d99fbf35910a9505035fb79daf409bf118aa
Reviewed-on: http://gerrit.tine20.com/customers/1584
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Tinebase/Record/Abstract.php

index 97eeaa0..cb96adf 100644 (file)
@@ -957,6 +957,13 @@ abstract class Tinebase_Record_Abstract implements Tinebase_Record_Interface
             if (in_array($fieldName, $this->_datetimeFields)) {
                 if ($ownField instanceof DateTime
                     && $recordField instanceof DateTime) {
+                    
+                    if (! $ownField instanceof Tinebase_DateTime) {
+                        if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . 
+                            ' Convert ' . $fieldName .' to Tinebase_DateTime to make sure we have the compare() method');
+                        $ownField = new Tinebase_DateTime($ownField);
+                    }
+                        
                     if ($ownField->compare($recordField) === 0) {
                         continue;
                     } else {