From a6bb4cee44b7585d1221632d5a87f1d9001f4874 Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Tue, 29 Dec 2015 17:02:07 +0530 Subject: [PATCH] CRM-17668 - logging revert: boolean breaks if reverting to null --- CRM/Logging/Reverter.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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') { -- 2.25.1