View Issue Details

This bug affects 1 person(s).
 10
IDProjectCategoryView StatusLast Update
13821Bug reportsImport/Exportpublic2020-03-06 00:43
ReporterMerkOne Assigned ToLouisGac 
PrioritynoneSeverityblock 
Status closedResolutionfixed 
Product Version3.12.x 
Fixed in Version3.22.7 
Summary13821: When importing a survey I receive a "Failed to Insert [3]" error message
Description

Exporting survey from Live webserver, importing into local webserver. The import creates the survey, the 1st question group and an empty question and then throws the error. I also receive the same error when importing just a question group. Importing a question by itself works (kind of - another bug report).

Steps To Reproduce

Create survey on Live webserver
Export the survey

Log into local hosted version
Select Import Survey
Follow the steps

Error occurs

Additional Information

I have also seen a DBCommand error once, but have been unable to reproduce.

This problem also seems to affect creating a question, when creating a question and pressing "Save" it takes me to a blank page. Pressing back shows the question was created. This doesnt occur if I press "Save and New"

TagsNo tags attached.
Bug heat10
Complete LimeSurvey version number (& build)3.12.2+180625 & 3.12.3
I will donate to the project if issue is resolvedNo
BrowserChrome
Database type & versionsqlsrv
Server OS (if known)Linux 3.10.0-514.el7.x86_64 #1 SMP
Webserver software & version (if known)Apache/2.4.6 (Red Hat Enterprise Linux)
PHP Version7.0.30

Relationships

related to 13822 closedc_schmitz Importing a question with subquestions, promotes subquestions to same level as parent 

Users monitoring this issue

efingdmi

Activities

c_schmitz

c_schmitz

2018-06-27 14:31

administrator   ~48318

I cannot reproduce that in 3.12.3
Please update and let us know if it works now.

MerkOne

MerkOne

2018-06-27 14:37

reporter   ~48320

I have updated with the latest ComfortUpdate & am still seeing this error.

MerkOne

MerkOne

2018-06-27 16:20

reporter   ~48348

Further note, if I press "Create Question Group" directly after the import fails, I see this error;

Internal Server Error
CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Incorrect syntax near '='.
An internal error occurred while the Web server was processing your request. Please contact the webmaster to report this problem.

MerkOne

MerkOne

2018-06-28 15:26

reporter   ~48362

I have grabbed the latest source code from GitHub, configured it to be hosted locally and pointed at a local SQL database. I have then tried to import a survey exported from the Live version (hosted here) and it throws the "Error: Failed to insert data [3]" message.

So definitely nothing to do with my hosted version.

I'm going to try and debug it next.

MerkOne

MerkOne

2018-06-28 17:33

reporter   ~48376

Confirmed that this is still an issue in the latest ComfortUpdate.

LouisGac

LouisGac

2018-06-28 18:04

developer   ~48379

Hi, I'll try to reproduce it tomorow.
It seems to affect only linux mssql server client.
Why don't you use MySQL by the way? Why mssql?

efingdmi

efingdmi

2018-06-29 09:54

reporter   ~48386

Hi all,
same for me using:
LimeSurvey 3.13.0
Windows Server 2012 R2 64Bit
MS SQL Server 2016
Apache Apache 2.4.33 (64bit)
PHP 7.2.6 (64bit)

additional Information: Despite this error message, the survey gets imported, but only with question groups and without questions!

MerkOne

MerkOne

2018-06-29 11:28

reporter   ~48396

Why don't you use MySQL by the way? Why mssql?

Client requirements I'm afraid, they are a MSSQL shop.

c_schmitz

c_schmitz

2018-06-29 14:41

administrator   ~48410

Last edited: 2018-06-29 14:42

How does your freetds.conf look like?

MerkOne

MerkOne

2018-06-29 15:05

reporter   ~48413

I dont appear to have a freetds.conf file on my local machine (Windows) which is displaying the error. I'll try and grab the copy of the RedHat box which is also experiencing the problem.

MerkOne

MerkOne

2018-07-02 11:11

reporter   ~48429

I have put in a pull request to address the fix. The issue is that the SQL PDO driver has changed its implementation so if you pass in a sequence name, it will always try and get a ID from a sequence, even on MSSQL. Comment from the code;

"Before version 5.0, the SQLSRV driver supports PDO::lastInsertId() with one peculiarity: when $sequence's value is null or empty string it returns empty string. But when parameter is not specified at all it's working as expected and returns actual last inserted ID (like other PDO drivers). 5.0 of the Microsoft PHP Drivers for SQL Server changes the behaviour of PDO::lastInsertID to be consistent with the behaviour outlined in the PDO documentation. It returns the ID of the last inserted sequence or row."

This change has come from the tip of the yii-1.19-dev code I'm not sure if their will be a further release (yii 1.1x is at end of life).

Pull Request Here: https://github.com/LimeSurvey/LimeSurvey/pull/1090

MerkOne

MerkOne

2018-07-02 11:25

reporter   ~48431

The relevant yii commit is here: https://github.com/yiisoft/yii/commit/7b768c304289ede574768de68939224d1180e2b1

MerkOne

MerkOne

2018-07-05 15:27

reporter   ~48455

Hi,

any update on when this issue and\or pull request might be reviewed?

LouisGac

LouisGac

2018-07-09 10:59

developer   ~48466

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=27599

c_schmitz

c_schmitz

2020-03-06 00:43

administrator   ~56344

This version of LimeSurvey is not longer supported. Please check so that the issue is fixed in a more recent version of LimeSurvey. If it's not, reopen this bug report. Thank you.

Related Changesets

LimeSurvey: master d69915c1

2018-07-09 10:59:44

githubLewis


Committer: LouisGac Details Diff
Fixed issue 13821: When importing a survey I receive a "Failed to Insert [3]" error message (#1090)

Dev: This issue is caused by a change in the sql pdo driver
Dev: without this fix, new ids aren't returned from tables with identity columns in mssql
Dev: This causes questions not to save correctly (import, new etc)
Dev: This fix is from the yii 1.19-dev label, commit:
Dev: Commit 7b768c304289ede574768de68939224d1180e2b1
Affected Issues
13821
mod - framework/db/schema/mssql/CMssqlSqlsrvPdoAdapter.php Diff File

Issue History

Date Modified Username Field Change
2018-06-27 12:07 MerkOne New Issue
2018-06-27 14:31 c_schmitz Assigned To => c_schmitz
2018-06-27 14:31 c_schmitz Status new => feedback
2018-06-27 14:31 c_schmitz Note Added: 48318
2018-06-27 14:37 MerkOne Note Added: 48320
2018-06-27 14:37 MerkOne Status feedback => assigned
2018-06-27 14:52 c_schmitz Assigned To c_schmitz => LouisGac
2018-06-27 16:20 MerkOne Note Added: 48348
2018-06-28 15:26 MerkOne Note Added: 48362
2018-06-28 17:33 MerkOne Note Added: 48376
2018-06-28 18:04 LouisGac Note Added: 48379
2018-06-29 09:54 efingdmi Note Added: 48386
2018-06-29 09:55 efingdmi Issue Monitored: efingdmi
2018-06-29 11:28 MerkOne Note Added: 48396
2018-06-29 14:41 c_schmitz Note Added: 48410
2018-06-29 14:42 c_schmitz Note Edited: 48410
2018-06-29 15:05 MerkOne Note Added: 48413
2018-07-02 11:11 MerkOne Note Added: 48429
2018-07-02 11:25 MerkOne Note Added: 48431
2018-07-02 11:37 MerkOne Issue Monitored: MerkOne
2018-07-02 11:37 MerkOne Issue End Monitor: MerkOne
2018-07-05 15:27 MerkOne Note Added: 48455
2018-07-09 10:59 LouisGac Changeset attached => LimeSurvey master d69915c1
2018-07-09 10:59 LouisGac Note Added: 48466
2018-07-09 10:59 LouisGac Resolution open => fixed
2019-05-23 09:56 c_schmitz Relationship added related to 13822
2020-03-06 00:43 c_schmitz Status assigned => closed
2020-03-06 00:43 c_schmitz Fixed in Version => 3.22.7
2020-03-06 00:43 c_schmitz Note Added: 56344
2021-08-02 17:13 guest Bug heat 8 => 10