From 68ff2516aaf81def4ad6d0837a1b53e8c20f5a03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Fl=C3=BCr?= Date: Sat, 15 Sep 2018 13:09:00 +0200 Subject: [PATCH] Fixed issue #14058: vvimport failing because of missing default values on newer MariaDB databases --- application/helpers/admin/import_helper.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/application/helpers/admin/import_helper.php b/application/helpers/admin/import_helper.php index f57c9bfce34..46870251016 100644 --- a/application/helpers/admin/import_helper.php +++ b/application/helpers/admin/import_helper.php @@ -2012,6 +2012,7 @@ function CSVImportResponses($sFullFilePath, $iSurveyId, $aOptions = array()) $oSurvey->submitdate = $aResponses[$iSubmitdateKey]; } } + foreach ($aKeyForFieldNames as $sFieldName=>$iFieldKey) { if ($aResponses[$iFieldKey] == '{question_not_shown}') { $oSurvey->$sFieldName = new CDbExpression('NULL'); @@ -2020,6 +2021,16 @@ function CSVImportResponses($sFullFilePath, $iSurveyId, $aOptions = array()) $oSurvey->$sFieldName = $sResponse; } } + + //Check if datestamp is set => throws no default error on importing + if(!isset($oSurvey->datestamp)){ + $oSurvey->datestamp = '1980-01-01 00:00:01'; + } + //Check if startdate is set => throws no default error on importing + if(!isset($oSurvey->startdate)){ + $oSurvey->startdate = '1980-01-01 00:00:01'; + } + // We use transaction to prevent DB error $oTransaction = Yii::app()->db->beginTransaction(); try { @@ -2052,8 +2063,8 @@ function CSVImportResponses($sFullFilePath, $iSurveyId, $aOptions = array()) $oTransaction->rollBack(); $aResponsesError[] = $aResponses[$iIdReponsesKey]; // Show some error to user ? - // $CSVImportResult['errors'][]=$oException->getMessage(); // Show it in view - // tracevar($oException->getMessage());// Show it in console (if debug is set) + $CSVImportResult['errors'][]=$oException->getMessage(); // Show it in view + tracevar($oException->getMessage());// Show it in console (if debug is set) } }