CRM-17668 - logging revert: boolean breaks if reverting to null
authorjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Tue, 29 Dec 2015 11:32:07 +0000 (17:02 +0530)
committerjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Tue, 29 Dec 2015 11:32:07 +0000 (17:02 +0530)
CRM/Logging/Reverter.php

index 9b95118a3268f9587e80aa7257ea7dd0f4caf7ee..6cb8a80370ba5a44d8884144048ee0e6a380d24d 100644 (file)
@@ -146,6 +146,7 @@ class CRM_Logging_Reverter {
               if (!isset($ctypes[$table][$field])) {
                 continue;
               }
+              $fldVal = "%{$counter}";
               switch ($ctypes[$table][$field]) {
                 case 'Date':
                   $value = substr(CRM_Utils_Date::isoToMysql($value), 0, 8);
@@ -154,10 +155,17 @@ class CRM_Logging_Reverter {
                 case 'Timestamp':
                   $value = CRM_Utils_Date::isoToMysql($value);
                   break;
+
+                case 'Boolean':
+                  if ($value === '') {
+                    $fldVal = 'DEFAULT';
+                  }
               }
               $inserts[$field] = "%$counter";
-              $updates[] = "$field = %$counter";
-              $params[$counter] = array($value, $ctypes[$table][$field]);
+              $updates[] = "{$field} = {$fldVal}";
+              if ($fldVal != 'DEFAULT') {
+                $params[$counter] = array($value, $ctypes[$table][$field]);
+              }
               $counter++;
             }
             if ($changes['log_action'] == 'Delete') {