Skip to content

Commit

Permalink
Fixed issue #14058: vvimport failing because of missing default value…
Browse files Browse the repository at this point in the history
…s on newer MariaDB databases
  • Loading branch information
lacrioque committed Sep 15, 2018
1 parent d21f31c commit 68ff251
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions application/helpers/admin/import_helper.php
Expand Up @@ -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');
Expand All @@ -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 {
Expand Down Expand Up @@ -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)
}

}
Expand Down

0 comments on commit 68ff251

Please sign in to comment.