View Issue Details

This bug affects 1 person(s).
 4
IDProjectCategoryView StatusLast Update
06137Bug reportsImport/Exportpublic2012-06-20 14:09
Reporteruser9189Assigned Touser9189 
PrioritynormalSeverityblock 
Status closedResolutionfixed 
Product Version2.00RC2 
Fixed in Version2.00RC2 
Summary06137: Import Excel survey structure leads to database crash
Description

When importing a survey with Import Excel survey structure, I get this error:

CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '900-en' for key 'PRIMARY'. The SQL statement executed was: INSERT INTO lime_questions (parent_qid, sid, gid, type, title, other, scale_id, same_default, question, relevance, preg, help, language, mandatory, qid, question_order) VALUES (:yp0, :yp1, :yp2, :yp3, :yp4, :yp5, :yp6, :yp7, :yp8, :yp9, :yp10, :yp11, :yp12, :yp13, :yp14, :yp15)

Steps To Reproduce
  1. Import the attached survey (.lss format). This is a survey that I ran without problems in LS v1.92.
  2. Export the survey to Excel Structure
  3. Make no changes to the Excel Structure file, and import directly.
Additional Information

I pulled the latest Yii branch this morning, cleared the database and ran the installer. In other words, this is a completely clean installation.

TagsNo tags attached.
Attached Files
Bug heat4
Complete LimeSurvey version number (& build)9999
I will donate to the project if issue is resolvedNo
BrowserAny
Database type & versionmysql 5.5.22
Server OS (if known)Linux
Webserver software & version (if known)Apache 2.0
PHP VersionVersion 5.3.10-1ubuntu3.1

Users monitoring this issue

There are no users monitoring this issue.

Activities

TMSWhite

TMSWhite

2012-05-27 13:21

reporter   ~18917

Please attach the survey

TMSWhite

TMSWhite

2012-05-27 15:20

reporter   ~18919

Please also check the "Show Logic File" (http://docs.limesurvey.org/Show+Logic+File) for your survey. If there are any question names (column 2) shown in red with a pink line around them, then you have errors in your survey that will prevent re-import without first fixing them. The easiest way to do so is to export the survey to Excel (that will work fine). Then, you need to change the problem question names so that you have unique, valid variable names for the import to work. Otherwise, you will get the duplicate key violations you describe.

user9189

2012-05-27 17:12

  ~18924

File uploaded. Sorry, I thought I did it the first time.

You are exactly correct in your suggestion about red with pink borders. This is indeed the case, but I missed that when I looked at the file, since the text at the top says "No syntax errors detected in this survey."

Three suggestions, then:

  1. Modify logic file page to say something like "There are invalid question names".
  2. When exporting the survey structure, issue a warning about some of the issues.
  3. But most importantly, when importing, we should issue a graceful error message that indicates the issue (and possibly some tips for fixing it), rather than a database crash.
TMSWhite

TMSWhite

2012-05-27 17:20

reporter   ~18925

The file you uploaded imports fine. Although all of the question names have warnings, none of them is duplicated.

That is the true root cause - if you re-use the same question code for multiple questions, you will get the import error. You should, but are not required, to also ensure that the question names are all valid.

Yes, more graceful error messages would be helpful, rather than calling "safe_die". Moreover, if the file partially loads but doesn't succeed, the whole survey should be deleted so that you don't have dangling partial surveys.

user9189

2012-05-27 17:30

  ~18926

Yes, the file I uploaded is the valid lss file, not the excel survey structure file. To replicate: import the lss, export to survey structure, import survey structure.

I am now working through the Excel file to try and get it to a point where I can import. I have already renamed all the questions to Q1, Q2, etc. Still no luck.

I am in the #limesurvey-team IRC channel at the moment, if you want to continue the discussion there.

TMSWhite

TMSWhite

2012-05-27 20:39

reporter   ~18928

Andrie - thanks for taking a stab at these.

user9189

2012-05-30 14:31

  ~18998

Committed partial fix.

Added:

  • Error checking for errors in question and answer importing
  • Array of error messages (and excel line numbers) get displayed on completion

Related Changesets

LimeSurvey: Yii 4e48eded

2012-05-30 05:30:18

user9189

Details Diff
Fixed issue 06137: Import Excel survey structure leads to database crash
<Dev> Added try/catch mechanism for Answers::model()->insertRecords() and Questions::model()->insertRecords()
<Dev> Added descriptive error messages
Affected Issues
06137
mod - application/controllers/admin/surveyadmin.php Diff File
mod - application/helpers/admin/import_helper.php Diff File
mod - application/models/Answers.php Diff File
mod - application/models/Questions.php Diff File
mod - application/views/admin/survey/importSurvey_view.php Diff File

LimeSurvey: Yii 4de3339f

2012-05-30 07:41:51

DenisChenu


Committer: user9189 Details Diff
Fixed issue 06137: Import Excel survey structure leads to database crash
<Dev> Delete temporary survey when errors are found
Affected Issues
06137
mod - application/helpers/admin/import_helper.php Diff File

Issue History

Date Modified Username Field Change
2012-05-27 11:15 user9189 New Issue
2012-05-27 11:15 user9189 Status new => assigned
2012-05-27 11:15 user9189 Assigned To => TMSWhite
2012-05-27 11:17 user9189 Additional Information Updated
2012-05-27 13:21 TMSWhite Note Added: 18917
2012-05-27 15:20 TMSWhite Note Added: 18919
2012-05-27 17:02 user9189 File Added: limesurvey_survey_96553 2011-06-02.lss
2012-05-27 17:12 user9189 Note Added: 18924
2012-05-27 17:20 TMSWhite Note Added: 18925
2012-05-27 17:30 user9189 Note Added: 18926
2012-05-27 20:39 TMSWhite Assigned To TMSWhite => user9189
2012-05-27 20:39 TMSWhite Note Added: 18928
2012-05-30 14:31 user9189 Note Added: 18998
2012-05-30 14:33 user9189 Status assigned => resolved
2012-05-30 14:33 user9189 Fixed in Version => 2.00RC2
2012-05-30 14:33 user9189 Resolution open => fixed
2012-05-31 17:05 TMSWhite Changeset attached => LimeSurvey Yii 4de3339f
2012-05-31 17:05 TMSWhite Changeset attached => LimeSurvey Yii 4e48eded
2012-06-20 14:09 c_schmitz Status resolved => closed