View Issue Details

This bug affects 1 person(s).
 4
IDProjectCategoryView StatusLast Update
14649Bug reportsSurvey editingpublic2019-04-30 09:11
Reporterlemeurt Assigned ToDenisChenu  
PrioritynoneSeverityblock 
Status closedResolutionfixed 
Product Version3.15.x 
Fixed in Version3.17.x 
Summary14649: CDbException when a "default answer" option is not compatible with a question type
Description

Changing the question type on a question with an incompatible "default answer" option may lead to a CDbException when taking the survey.

Proposed patch: When updating a question type, either reset the default answers or selectively reset the default answers if the new question type is not compliant with the previous one.

Steps To Reproduce
  • Create a question of type text
  • Add a long default answer as text
  • Change the question type to List Dropdown
  • add answers (the code is 5 Chars max)
  • activate the survey (the answer table prepares a varying(5) field type
  • Try to answer the survey ==> Error 500 Internal Server Error
    CDbCommand n'a pas pu exécuter la commande SQL: SQLSTATE[22001]: String data, right truncated: 7 ERROR: value too long for type character varying(5)
Additional Information

Detailed error with Debugging:

CDbCommand n'a pas pu exécuter la commande SQL: SQLSTATE[22001]: String data, right truncated: 7 ERROR: value too long for type character varying(5)

CDbException

CDbCommand n'a pas pu exécuter la commande SQL: SQLSTATE[22001]: String data, right truncated: 7 ERROR: value too long for type character varying(5). The SQL statement executed was: UPDATE lime_survey_114132 SET "lastpage"=0, "114132X202X1951"='1A CentraleSupélec 2A cursus centralien 2A cursus Supélec', "114132X202X1956"='Oui Non Ne sait pas encore' WHERE ID=601 (/var/www/html/limesurvey/framework/db/CDbCommand.php:543)

#0 /var/www/html/limesurvey/framework/db/CDbCommand.php(377): CDbCommand->queryInternal('', 0, Array)
#1 /var/www/html/limesurvey/application/helpers/expressions/em_manager_helper.php(5565): CDbCommand->query()
#2 /var/www/html/limesurvey/application/helpers/expressions/em_manager_helper.php(5290): LimeExpressionManager->_UpdateValuesInDatabase()
#3 /var/www/html/limesurvey/application/helpers/SurveyRuntimeHelper.php(838): LimeExpressionManager::NavigateForwards()
#4 /var/www/html/limesurvey/application/helpers/SurveyRuntimeHelper.php(537): SurveyRuntimeHelper->setMoveResult()
#5 /var/www/html/limesurvey/application/helpers/SurveyRuntimeHelper.php(104): SurveyRuntimeHelper->initMove()
#6 /var/www/html/limesurvey/application/controllers/survey/index.php(591): SurveyRuntimeHelper->run('114132', Array)
#7 /var/www/html/limesurvey/application/controllers/survey/index.php(24): index->action()
#8 /var/www/html/limesurvey/framework/web/actions/CAction.php(76): index->run()
#9 /var/www/html/limesurvey/framework/web/CController.php(308): CAction->runWithParams(Array)
#10 /var/www/html/limesurvey/framework/web/CController.php(286): CController->runAction(Object(index))
#11 /var/www/html/limesurvey/framework/web/CController.php(265): CController->runActionWithFilters(Object(index), Array)
#12 /var/www/html/limesurvey/framework/web/CWebApplication.php(282): CController->run('index')
#13 /var/www/html/limesurvey/framework/web/CWebApplication.php(141): CWebApplication->runController('survey/index/si...')
#14 /var/www/html/limesurvey/framework/base/CApplication.php(185): CWebApplication->processRequest()
#15 /var/www/html/limesurvey/index.php(194): CApplication->run()
#16 {main}

TagsNo tags attached.
Attached Files
Bug heat4
Complete LimeSurvey version number (& build)Version 3.15.8+190130
I will donate to the project if issue is resolvedNo
Browser
Database type & versionPostgres and mariaDB 10.3.12
Server OS (if known)
Webserver software & version (if known)
PHP VersionN/A

Relationships

related to 10827 closedDenisChenu Whole answers must be filtered before try to save in DB 
related to 14768 closeddominikvitt Survey fails when default answer is set 

Users monitoring this issue

There are no users monitoring this issue.

Activities

DenisChenu

DenisChenu

2019-03-14 12:20

developer   ~50981

2 patch must be done

  1. must fix the CDB value even with invalid value
  2. Auto fif default value in GUI

PS : a cool way to have a default value for single choice. When 1 is fixed : we can add a input:text for singlme choice too (like with Yes/No question type).

DenisChenu

DenisChenu

2019-03-14 12:24

developer   ~50982

Related to https://bugs.limesurvey.org/view.php?id=10827 because it does the same things for user entered value (filter $_POST before set).
For default value : error can be shown, but maybe only for user with edit content rights on survey ?

lemeurt

lemeurt

2019-03-15 11:34

reporter   ~51002

Hi Denis,
10827 is private, I can't access it.

DenisChenu

DenisChenu

2019-03-15 11:58

developer   ~51003

I set 10827 public since it was private due to security.
You can find the fix here : https://github.com/LimeSurvey/LimeSurvey/commit/6c7c30d13a9cb45aee498cf4d3eb0a5c8b06ed19

The big part is https://github.com/LimeSurvey/LimeSurvey/commit/6c7c30d13a9cb45aee498cf4d3eb0a5c8b06ed19#diff-796aba4d06254b9caea9d461e4ea80c9R10238
Maybe adding an optionnal settings private static function checkValidityAnswer($type,$value,$sgq,$qinfo,$setInvalidAnswerString = true)
And use it to filter default value ?

lemeurt

lemeurt

2019-03-15 22:31

reporter   ~51021

Just to let write down that this is only a major bug for Postgres users as in Mysql when trying to insert too much data in a short database column, the data is automatically truncated without throwing Exceptions.

DenisChenu

DenisChenu

2019-03-29 19:38

developer   ~51212

Same issue with mariadDB, send a lss, but unsure it work when import.

CDbException.html (25,789 bytes)   
DenisChenu

DenisChenu

2019-03-30 18:56

developer   ~51222

https://github.com/LimeSurvey/LimeSurvey/pull/1252

DenisChenu

DenisChenu

2019-04-05 08:55

developer   ~51361

merged

Issue History

Date Modified Username Field Change
2019-03-14 11:42 lemeurt New Issue
2019-03-14 12:20 DenisChenu Note Added: 50981
2019-03-14 12:23 DenisChenu Relationship added related to 10827
2019-03-14 12:24 DenisChenu Note Added: 50982
2019-03-15 11:34 lemeurt Note Added: 51002
2019-03-15 11:58 DenisChenu Note Added: 51003
2019-03-15 22:31 lemeurt Note Added: 51021
2019-03-29 19:34 DenisChenu Assigned To => DenisChenu
2019-03-29 19:34 DenisChenu Status new => assigned
2019-03-29 19:37 DenisChenu Database & DB-Version Postgres => Postgres and mariaDB 10.3.12
2019-03-29 19:38 DenisChenu File Added: 500: Internal Server Error.html
2019-03-29 19:38 DenisChenu File Added: CDbException.html
2019-03-29 19:38 DenisChenu File Added: survey_archive_BadDefault.lsa
2019-03-29 19:38 DenisChenu Note Added: 51212
2019-03-30 18:56 DenisChenu Note Added: 51222
2019-04-05 08:55 DenisChenu Status assigned => resolved
2019-04-05 08:55 DenisChenu Resolution open => fixed
2019-04-05 08:55 DenisChenu Fixed in Version => 3.17.x
2019-04-05 08:55 DenisChenu Note Added: 51361
2019-04-24 17:00 DenisChenu Relationship added related to 14768
2019-04-30 09:11 c_schmitz Status resolved => closed
2019-11-01 17:25 c_schmitz Category Survey design => Survey editing