Skip to content

Commit

Permalink
Fixed issue #12227: "Error: Failed to insert data" and corrupted quot…
Browse files Browse the repository at this point in the history
…as when i've tried to import old (v2.5.xx) surveys
  • Loading branch information
dominikvitt committed May 28, 2018
1 parent c8a30e1 commit 91b646d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions application/helpers/admin/import_helper.php
Expand Up @@ -1462,6 +1462,7 @@ function XMLImportSurvey($sFullFilePath, $sXMLdata = null, $sNewSurveyName = nul
foreach ($row as $key=>$value) {
$insertdata[(string) $key] = (string) $value;
}
$insertdata['autoload_url'] = 0; // used to bypass urlValidator check in QuotaLanguageSetting model
$insertdata['quotals_quota_id'] = $aQuotaReplacements[(int) $insertdata['quotals_quota_id']]; // remap the qid
unset($insertdata['quotals_id']);
$result = QuotaLanguageSetting::model()->insertRecords($insertdata) or safeDie(gT("Error").": Failed to insert data<br />");
Expand Down
8 changes: 6 additions & 2 deletions application/models/QuotaLanguageSetting.php
Expand Up @@ -96,8 +96,12 @@ public function insertRecords($data)
{
$settings = new self;
foreach ($data as $k => $v) {
$settings->$k = $v;
}
if ($k === 'autoload_url'){
$settings->quota->autoload_url = $v;
} else {
$settings->$k = $v;
}
}
return $settings->save();
}
}

2 comments on commit 91b646d

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\o/ thank you :)

Again : this model()->insertRecords function is awfull and must be destructed (whene using clean function : we can show exact error …)

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dominikvitt maybe we just need to on exception on this rules ?
example :

array('title', 'length', 'min' => 1, 'max'=>20, 'on' => 'update, insert'),
for rules only when
example for exception :
'except' => 'archiveimport');

:)

Please sign in to comment.