View Issue Details

This bug affects 1 person(s).
 4
IDProjectCategoryView StatusLast Update
16708Bug reportsStatisticspublic2020-10-12 09:28
Reporterannighoefer Assigned Togabrieljenik  
PrioritynoneSeverityminor 
Status closedResolutionfixed 
Product Version4.3.16 
Summary16708: php error in statistics view
Description

Hello,

i get an error if I wanna see statistics in simple mode of a survey.

Steps To Reproduce

The error can be reproduced by following these steps:

  1. The user creates a question of type array (F) with subquestions
  2. Later, the user changes the type of question to Type L (List Radio)
  3. User activate the survey
  4. After limesurvey security updates, we run the data integrity check.
  5. After integrity check, we get this error in the simple statistics view mode of the survey where the question type was changed.
Additional Information

The problem is, parent question and subquestions are different types (Parent (L), Subquestion (F)). The data integrity check sets the type of subquestion equal to parent question. This means, the subquestion is of type L now. This happens in function fixSubQuestions() located in Question.php. I think statistics can't handle subquestions of type L or other types.

TagsNo tags attached.
Attached Files
Bug heat4
Complete LimeSurvey version number (& build)4.3.16+202009
I will donate to the project if issue is resolvedNo
Browser
Database type & versionMySQL [5.5.5-10.1.45-MariaDB-0+deb9u1]
Server OS (if known)18.04.1-Ubuntu
Webserver software & version (if known)Apache
PHP Version7.2.33

Users monitoring this issue

There are no users monitoring this issue.

Activities

gabrieljenik

gabrieljenik

2020-10-07 19:58

manager   ~60111

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

Diagnosis

According to the description of the issue we believe to be caused by a combination of errors:

1) When changing the type of a question from a type with subquestions to a type without subquestions (ex: from Array to List), the subquestions are not removed from the DB. The subquestions remain in the table with the old type.

2) Check Integrity processes these "orphan" subquestions making sure they match the parent question's type, without checking if it's actually correct for that type to have subquestions. So, it updates the subquestions while it should remove them.

I think both actions should check the question type definition (QuestionType attributes) and, if the 'subquestions' attribute is false, remove the subquestions from the DB.

Solution

1) Override 'update' method in Question model to delete existing subquestions if the question's type doesn't allow them.

2) Updated saveQuestionData action to avoid saving subquestions if the question's type doesn't allow them (because the subquestions are part the POST if they exist in the original question).

3) Updated common_helper's 'fixSubquestions' (used by check integrity) to do the same as mentioned in point 1.

Note that 'fixSubquestions' only processes subquestions where the type is not the same as the parent question. This wasn't modified because of the potential impact in performance, but it means it won't fix subquestions of a wrong type if the parent question has the same type.

gabrieljenik

gabrieljenik

2020-10-08 09:17

manager   ~60113

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

lime_release_bot

lime_release_bot

2020-10-12 09:28

administrator   ~60145

Fixed in Release 4.3.20+201012

Related Changesets

LimeSurvey: master 076d6d0e

2020-10-08 11:17

gabrieljenik

Committer: GitHub


Details Diff
Fixed issue 16708: php error in statistics view (#1616)

### Diagnosis

According to the description of the issue we believe to be caused by a combination of errors:

1) When changing the type of a question from a type with subquestions to a type without subquestions (ex: from Array to List), the subquestions are not removed from the DB. The subquestions remain in the table with the old type.

2) Check Integrity processes these "orphan" subquestions making sure they match the parent question's type, without checking if it's actually correct for that type to have subquestions. So, it updates the subquestions while it should remove them.

I think both actions should check the question type definition (QuestionType attributes) and, if the 'subquestions' attribute is false, remove the subquestions from the DB.

### Solution

1) Override 'update' method in Question model to delete existing subquestions if the question's type doesn't allow them.

2) Updated saveQuestionData action to avoid saving subquestions if the question's type doesn't allow them (because the subquestions are part the POST if they exist in the original question).

3) Updated common_helper's 'fixSubquestions' (used by check integrity) to do the same as mentioned in point 1.

Note that 'fixSubquestions' only processes subquestions where the type is not the same as the parent question. This wasn't modified because of the potential impact in performance, but it means it won't fix subquestions of a wrong type if the parent question has the same type.
Affected Issues
16708
mod - application/controllers/QuestionEditorController.php Diff File
mod - application/helpers/common_helper.php Diff File
mod - application/models/Question.php Diff File

Issue History

Date Modified Username Field Change
2020-09-30 08:44 annighoefer New Issue
2020-09-30 08:44 annighoefer File Added: Bildschirmfoto 2020-09-29 um 14.36.17.png
2020-09-30 08:44 annighoefer File Added: Bildschirmfoto 2020-09-29 um 15.05.58.png
2020-10-02 12:42 cdorin Assigned To => gabrieljenik
2020-10-02 12:42 cdorin Status new => assigned
2020-10-07 19:58 gabrieljenik Note Added: 60111
2020-10-08 09:17 gabrieljenik Changeset attached => LimeSurvey master 076d6d0e
2020-10-08 09:17 gabrieljenik Note Added: 60113
2020-10-08 09:17 gabrieljenik Resolution open => fixed
2020-10-12 09:28 lime_release_bot Note Added: 60145
2020-10-12 09:28 lime_release_bot Status assigned => closed