From: jitendrapurohit Date: Tue, 29 Dec 2015 11:32:07 +0000 (+0530) Subject: CRM-17668 - logging revert: boolean breaks if reverting to null X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=a6bb4cee44b7585d1221632d5a87f1d9001f4874;p=civicrm-core.git CRM-17668 - logging revert: boolean breaks if reverting to null --- diff --git a/CRM/Logging/Reverter.php b/CRM/Logging/Reverter.php index 9b95118a32..6cb8a80370 100644 --- a/CRM/Logging/Reverter.php +++ b/CRM/Logging/Reverter.php @@ -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') {