View Issue Details

This bug affects 1 person(s).
 8
IDProjectCategoryView StatusLast Update
18019Bug reportsSurvey editingpublic2022-05-24 15:16
ReporterDenisChenu Assigned Togabrieljenik  
PriorityhighSeverityminor 
Status closedResolutionfixed 
Product Version5.2.x 
Summary18019: 500 error in question edition (bad code on question)
Description

See screencast , entering invalid code broke whole page.

Steps To Reproduce

Steps to reproduce

See screencast
Make the same with 3.X

Expected result

  1. Have a clean error returned
  2. Can edit invalid code just after (3.X is not perfect, updating code is not the best solution, but it's better than broke).

Actual result

Broke

TagsNo tags attached.
Bug heat8
Complete LimeSurvey version number (& build)5.3.8
I will donate to the project if issue is resolvedNo
Browsernot relevant
Database type & versionnot relevant
Server OS (if known)not relevant
Webserver software & version (if known)not relevant
PHP Versionnot relevant

Relationships

related to 17929 closedDenisChenu Bad code can be entered and savec in answer code 
related to 18032 assignedgabrieljenik LSJsonExceptions handling and rendering 

Users monitoring this issue

User List There are no users monitoring this issue.

Activities

DenisChenu

DenisChenu

2022-04-05 16:35

developer  

3.X.gif (174,434 bytes)
5.X.gif (507,799 bytes)
DenisChenu

DenisChenu

2022-04-05 16:36

developer   ~68896

PS : adding pattern and required must be done AFTER fix it in PHP (never think user can not update HTML)

DenisChenu

DenisChenu

2022-04-05 17:04

developer   ~68898

See (after https://github.com/LimeSurvey/LimeSurvey/pull/2331)
When using Save : it's really NEAR the best solution : stay there, don't update anything and don't save invalid value.

Still 2 issue :

  • Use a better view (not a print_r)
  • Save other answer (and show error if needed)
5XsaveAnswers.gif (638,254 bytes)
gabrieljenik

gabrieljenik

2022-04-05 19:26

manager   ~68902

So, we need complement this solution (https://github.com/LimeSurvey/LimeSurvey/pull/2331) by showing friendlier errors?

DenisChenu

DenisChenu

2022-04-05 19:49

developer   ~68903

Last edited: 2022-04-05 19:50

No : this issue is related to sub-question code.

BUT : answer code have same issue :) then must be fixed in same way :)

[EDIT] subquestion save (bot save and close) don't throw 500 error

gabrieljenik

gabrieljenik

2022-04-07 14:29

manager   ~68922

Now that 17929 is fixed, do we need this?

DenisChenu

DenisChenu

2022-04-07 16:25

developer   ~68928

See screencast : not related to answer code , but to sub-question code ,
Then we still need it (for subquestion)

Using save : it's OK
Using save and close : it's broken.

gabrieljenik

gabrieljenik

2022-04-07 18:34

manager   ~68935

The validation is already happening at subquestion level.

The error that you were shown is OK. Seems like a dump but I guess that's because of the debug mode?
We couldn't reproduce it exactly like that on 5.3

BTW: Answer Codes with strange characters were saved, no dumps. It is not supposed to accept those characters, so the rules added on the other ticket are fine.

image.png (20,194 bytes)   
image.png (20,194 bytes)   
image-2.png (81,940 bytes)   
image-2.png (81,940 bytes)   
DenisChenu

DenisChenu

2022-04-07 18:52

developer   ~68936

No need debug at 2 :
see screencast ,

  1. "Save and close" => throw 500 error
  2. "Save" => Better , didn't loose anything, but
    1. Error shown is ugly (and must be improved)
    2. Show only the 1st error
Peek 07-04-2022 18-50.gif (549,185 bytes)
DenisChenu

DenisChenu

2022-04-07 18:53

developer   ~68937

gabrieljenik

gabrieljenik

2022-04-08 23:07

manager   ~68956

Last edited: 2022-04-08 23:09

Save and Close button is not submitting the form through Ajax.
From what I see, the save controller can't handle errors in a non-ajax way.
Option 1: Update how controller send errors to front in non-ajax cases.
Option 2: Make "save and close" to send Ajax and also work on a call back to redirect to "view mode" after.

DenisChenu

DenisChenu

2022-04-09 15:50

developer   ~68963

Option 3 : send ->validate in ajax (and return error) and ->save in PHP

:)

gabrieljenik

gabrieljenik

2022-04-12 23:51

manager   ~69025

Last edited: 2022-04-12 23:56

Adding an error handler for the case when the save is not done using ajax.

Although it now shows the error in an alert, its content is still ugly (the print_r is still there).
It could be necessary to add validations in JS, because although now it does not throw the 500 error, it makes a redirect, and therefore the data is lost.

Side note, to review later: LSJsonExceptions are supposed to be handled by the SurveysController in the actionError() method, only when it's an AJAX request. But when it's AJAX it never gets there, because it gets caught before LSYii_Application::onException() (line 403). It would be necessary to add one more condition to that IF, excluding the LSJsonException. (will create a ticket for that)

PR: https://github.com/LimeSurvey/LimeSurvey/pull/2343

DenisChenu

DenisChenu

2022-04-13 09:51

developer   ~69036

Here : https://github.com/LimeSurvey/LimeSurvey/blob/cd03fc7ed0d2840b4462994e5e4dc1a340b63796/application/core/LSYii_Application.php#L402

gabrieljenik

gabrieljenik

2022-04-28 10:42

manager   ~69281

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

LimeBot

LimeBot

2022-05-02 10:33

administrator   ~69333

Fixed in Release 5.3.12+220502

Mazi

Mazi

2022-05-24 14:01

updater   ~69997

I get the exact same error as shown at https://bugs.limesurvey.org/file_download.php?file_id=15813&type=bug when trying to use "other" as subquestion code at an array question.
The error message ois misleading though:
"An error happened: Could not save subquestion Array ( [title] => Array ( [0] => 'other' can not be used if the 'Other' option for this question is activated. ) )"

-> There simply is no "other" option for array questions. So to make array filter work with e.g. a multi choice question with "other" field, it would be great if we could accept "other" as subquestion code for arrays.

image-3.png (84,484 bytes)   
image-3.png (84,484 bytes)   
gabrieljenik

gabrieljenik

2022-05-24 15:16

manager   ~70002

I get the exact same error as shown at https://bugs.limesurvey.org/file_download.php?file_id=15813&type=bug when trying to use "other" as subquestion code at an array question.

Correct link to file is https://bugs.limesurvey.org/file_download.php?file_id=15813&type=bug :)
Also, the message n that file is different than the screenshot, isn't it?

@mazi I hate to ask for this, but can I ask you to open a new ticket for this matter?

Related Changesets

LimeSurvey: master 77f5e93a

2022-04-28 10:42:35

gabrieljenik


Committer: GitHub Details Diff
Fixed issue 18019: 500 error in question edition (bad code on question) (#2343)

Co-authored-by: encuestabizdevgit <devgit@encuesta.biz>
Affected Issues
18019
mod - application/controllers/QuestionAdministrationController.php Diff File

Issue History

Date Modified Username Field Change
2022-04-05 16:35 DenisChenu New Issue
2022-04-05 16:35 DenisChenu File Added: 3.X.gif
2022-04-05 16:35 DenisChenu File Added: 5.X.gif
2022-04-05 16:36 DenisChenu Note Added: 68896
2022-04-05 16:36 DenisChenu Bug heat 0 => 2
2022-04-05 16:58 galads Assigned To => gabrieljenik
2022-04-05 16:58 galads Priority none => high
2022-04-05 16:58 galads Status new => assigned
2022-04-05 17:04 DenisChenu Note Added: 68898
2022-04-05 17:04 DenisChenu File Added: 5XsaveAnswers.gif
2022-04-05 19:26 gabrieljenik Note Added: 68902
2022-04-05 19:26 gabrieljenik Bug heat 2 => 4
2022-04-05 19:49 DenisChenu Note Added: 68903
2022-04-05 19:50 DenisChenu Note Edited: 68903
2022-04-07 14:28 gabrieljenik Relationship added related to 17929
2022-04-07 14:29 gabrieljenik Note Added: 68922
2022-04-07 16:25 DenisChenu Note Added: 68928
2022-04-07 18:34 gabrieljenik Note Added: 68935
2022-04-07 18:34 gabrieljenik File Added: image.png
2022-04-07 18:34 gabrieljenik File Added: image-2.png
2022-04-07 18:35 gabrieljenik Status assigned => ready for testing
2022-04-07 18:52 DenisChenu Note Added: 68936
2022-04-07 18:52 DenisChenu File Added: Peek 07-04-2022 18-50.gif
2022-04-07 18:53 DenisChenu Note Added: 68937
2022-04-07 18:53 DenisChenu File Added: Capture d’écran du 2022-04-07 18-53-06.png
2022-04-08 22:30 gabrieljenik Status ready for testing => assigned
2022-04-08 23:07 gabrieljenik Note Added: 68956
2022-04-08 23:09 gabrieljenik Note Edited: 68956
2022-04-09 15:50 DenisChenu Note Added: 68963
2022-04-12 23:51 gabrieljenik Note Added: 69025
2022-04-12 23:53 gabrieljenik Relationship added related to 18032
2022-04-12 23:54 gabrieljenik Status assigned => ready for testing
2022-04-12 23:56 gabrieljenik Note Edited: 69025
2022-04-13 09:51 DenisChenu Note Added: 69036
2022-04-28 10:42 gabrieljenik Changeset attached => LimeSurvey master 77f5e93a
2022-04-28 10:42 gabrieljenik Note Added: 69281
2022-04-28 10:42 gabrieljenik Resolution open => fixed
2022-05-02 10:33 LimeBot Note Added: 69333
2022-05-02 10:33 LimeBot Status ready for testing => closed
2022-05-02 10:33 LimeBot Bug heat 4 => 6
2022-05-24 14:01 Mazi Note Added: 69997
2022-05-24 14:01 Mazi File Added: image-3.png
2022-05-24 14:01 Mazi Bug heat 6 => 8
2022-05-24 15:16 gabrieljenik Note Added: 70002