Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Trivial
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.3.5
-
Fix Version/s: 4.4.0
-
Component/s: None
-
Labels:None
Description
[Error: Upgrade timestamps (100001 => 105000)]
Error Field Error Value
Type DB_Error
Code -1
Message DB Error: unknown error
Mode 16
UserInfo UPDATE civicrm_contact SET created_date = '2012-03-11 02:34:47', modified_date = '2012-03-11 02:34:47' WHERE id = 100410 [nativecode=1292 ** Incorrect datetime value: '2012-03-11 02:34:47' for column 'created_date' at row 1]
DebugInfo UPDATE civicrm_contact SET created_date = '2012-03-11 02:34:47', modified_date = '2012-03-11 02:34:47' WHERE id = 100410 [nativecode=1292 ** Incorrect datetime value: '2012-03-11 02:34:47' for column 'created_date' at row 1]
To replicate set modified date to '2012-03-11 02:34:47' on one or more entries in civicrm_log & tun the upgrade on a server with server time / mysql timezone set to US time.
2012-03-11 02:34:47 is not a valid time in the US due to daylight savings - it is valid in other countries.
The comments in the function show this as having been anticipated
/**
- Read creation and modification times from civicrm_log; add
- them to civicrm_contact.
*/
function convertTimestamps(CRM_Queue_TaskContext $ctx, $startId, $endId) {
$sql = "
SELECT entity_id, min(modified_date) AS created, max(modified_date) AS modified
FROM civicrm_log
WHERE entity_table = 'civicrm_contact'
AND entity_id BETWEEN %1 AND %2
GROUP BY entity_id
";
$params = array(
1 => array($startId, 'Integer'),
2 => array($endId, 'Integer'),
);
$dao = CRM_Core_DAO::executeQuery($sql, $params);
while ($dao->fetch()) { // FIXME civicrm_log.modified_date is DATETIME; civicrm_contact.modified_date is TIMESTAMP CRM_Core_DAO::executeQuery( 'UPDATE civicrm_contact SET created_date = %1, modified_date = %2 WHERE id = %3', array( 1 => array($dao->created, 'String'), 2 => array($dao->modified, 'String'), 3 => array($dao->entity_id, 'Integer'), ) ); }
return TRUE;
}
This is easily replicable in a test environment.
Note that I am going to convert the field to datetime on our customer's live site & re-run the upgrade.