Skip to content

Commit 200494b

Browse files
committedNov 21, 2011
Fix an edge case where invalid JSON is written the database. Fixes bug #12303.
1 parent b1133d9 commit 200494b

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed
 

‎docs/changelog/7.x.x.txt

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- fixed #12269: Login / Loginbox with encryptlogin
66
- fixed #12271: Calendar List View does not always show labels
77
- fixed Passive Analytics, UI, Progress Bar, server load.
8+
- fixed #12303: Survey custom multiple choice question types
89

910
7.10.23
1011
- fixed #12225: Stock asset, multiple instances on a page

‎docs/upgrades/upgrade_7.10.23-7.10.24.pl

+14
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ BEGIN
3434
addPALastLogTable($session);
3535
addForkRedirect($session);
3636
extendBucketName($session);
37+
fixSurveyQuestionTypes($session);
3738

3839
finish($session); # this line required
3940

@@ -81,6 +82,19 @@ sub extendBucketName {
8182
print "DONE!\n" unless $quiet;
8283
}
8384

85+
86+
#----------------------------------------------------------------------------
87+
# Describe what our function does
88+
sub fixSurveyQuestionTypes {
89+
my $session = shift;
90+
print "\tFix bad custom Question Types in the Survey... " unless $quiet;
91+
# and here's our code
92+
$session->db->write(<<EOSQL);
93+
update Survey_questionTypes set answers="{}" where answers like 'HASH%';
94+
EOSQL
95+
print "DONE!\n" unless $quiet;
96+
}
97+
8498
#----------------------------------------------------------------------------
8599
# Describe what our function does
86100
#sub exampleFunction {

‎lib/WebGUI/Asset/Wobject/Survey/SurveyJSON.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ sub addType {
169169
my $questionType = shift;
170170
my $address = shift;
171171
my $question = $self->question($address);
172-
my $ansString = $question->{answers} ? to_json $question->{answers} : {};
172+
my $ansString = $question->{answers} ? to_json $question->{answers} : '{}';
173173
$self->session->db->write("INSERT INTO Survey_questionTypes VALUES(?,?) ON DUPLICATE KEY UPDATE answers = ?",[$questionType,$ansString,$ansString]);
174174
$question->{questionType} = $questionType;
175175
}

0 commit comments

Comments
 (0)
Please sign in to comment.