Skip to content

Commit

Permalink
Fixed issue #14133: lss with long group name broke when import (#1138)
Browse files Browse the repository at this point in the history
Dev: since import_helper didn't have good error system … fix it silently
  • Loading branch information
Shnoulle committed Oct 15, 2018
1 parent a1ff015 commit 01a7131
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
13 changes: 7 additions & 6 deletions application/helpers/admin/import_helper.php
Expand Up @@ -933,7 +933,7 @@ function XMLImportSurvey($sFullFilePath, $sXMLdata = null, $sNewSurveyName = nul
}

if (!in_array($insertdata['surveyls_language'], $aLanguagesSupported)) {
continue;
continue;
}

// Assign new survey ID
Expand Down Expand Up @@ -995,7 +995,10 @@ function XMLImportSurvey($sFullFilePath, $sXMLdata = null, $sNewSurveyName = nul
$iOldSID = $insertdata['sid'];
$insertdata['sid'] = $iNewSID;
$oldgid = $insertdata['gid']; unset($insertdata['gid']); // save the old qid

if(strlen($insertdata['group_name']) > 100 ) { // see #14133 since this function didn't have good error system … must fix it silently …
$results['importwarnings'][] = sprintf(gT("Group “%s“ was set to “%s“"),CHtml::encode($insertdata['group_name']),CHtml::encode(substr($insertdata['group_name'],0,100)));
$insertdata['group_name'] = substr($insertdata['group_name'],0,100);
}
// now translate any links
if ($bTranslateInsertansTags) {
$insertdata['group_name'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['group_name']);
Expand All @@ -1007,8 +1010,7 @@ function XMLImportSurvey($sFullFilePath, $sXMLdata = null, $sNewSurveyName = nul
switchMSSQLIdentityInsert('groups', true);
$insertdata['gid'] = $aGIDReplacements[$oldgid];
}

$newgid = QuestionGroup::model()->insertRecords($insertdata) or safeDie(gT("Error").": Failed to insert data [3]<br />");
$newgid = QuestionGroup::model()->insertRecords($insertdata) or safeDie(gT("Error").": Failed to insert data [3]<br />");// This thrown safedie …
if (!isset($aGIDReplacements[$oldgid])) {
$aGIDReplacements[$oldgid] = $newgid; // add old and new qid to the mapping array
$results['groups']++;
Expand Down Expand Up @@ -1040,7 +1042,7 @@ function XMLImportSurvey($sFullFilePath, $sXMLdata = null, $sNewSurveyName = nul
$iOldSID = $insertdata['sid'];
$iOldGID = $insertdata['gid'];
$insertdata['sid'] = $iNewSID;
$insertdata['gid'] = $aGIDReplacements[$insertdata['gid']];
$insertdata['gid'] = $aGIDReplacements[$insertdata['gid']]; // Can add question with invalid gid … $newgid can be false …
$oldqid = $insertdata['qid']; unset($insertdata['qid']); // save the old qid

// now translate any links
Expand All @@ -1059,7 +1061,6 @@ function XMLImportSurvey($sFullFilePath, $sXMLdata = null, $sNewSurveyName = nul
XSSFilterArray($insertdata);
}


if (!$bConvertInvalidQuestionCodes) {
$sScenario = 'archiveimport';
} else {
Expand Down
1 change: 1 addition & 0 deletions application/models/QuestionGroup.php
Expand Up @@ -68,6 +68,7 @@ public function rules()
'message'=>'{attribute} "{value}" is already in use.'),
array('language', 'length', 'min' => 2, 'max'=>20), // in array languages ?
array('group_name,description', 'LSYii_Validators'),
array('group_name', 'length', 'min' => 0, 'max'=>100),
array('group_order', 'numerical', 'integerOnly'=>true, 'allowEmpty'=>true),
);
}
Expand Down

0 comments on commit 01a7131

Please sign in to comment.