Skip to content
Permalink
Browse files

Fix an edge case where invalid JSON is written the database. Fixes bu…

…g #12303.
  • Loading branch information...
perlDreamer committed Nov 21, 2011
1 parent b1133d9 commit 200494b28d1b1dd8b12f4914cbbb754e3a6b0704
@@ -5,6 +5,7 @@
- fixed #12269: Login / Loginbox with encryptlogin
- fixed #12271: Calendar List View does not always show labels
- fixed Passive Analytics, UI, Progress Bar, server load.
- fixed #12303: Survey custom multiple choice question types

7.10.23
- fixed #12225: Stock asset, multiple instances on a page
@@ -34,6 +34,7 @@ BEGIN
addPALastLogTable($session);
addForkRedirect($session);
extendBucketName($session);
fixSurveyQuestionTypes($session);

finish($session); # this line required

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


#----------------------------------------------------------------------------
# Describe what our function does
sub fixSurveyQuestionTypes {
my $session = shift;
print "\tFix bad custom Question Types in the Survey... " unless $quiet;
# and here's our code
$session->db->write(<<EOSQL);
update Survey_questionTypes set answers="{}" where answers like 'HASH%';
EOSQL
print "DONE!\n" unless $quiet;
}

#----------------------------------------------------------------------------
# Describe what our function does
#sub exampleFunction {
@@ -169,7 +169,7 @@ sub addType {
my $questionType = shift;
my $address = shift;
my $question = $self->question($address);
my $ansString = $question->{answers} ? to_json $question->{answers} : {};
my $ansString = $question->{answers} ? to_json $question->{answers} : '{}';
$self->session->db->write("INSERT INTO Survey_questionTypes VALUES(?,?) ON DUPLICATE KEY UPDATE answers = ?",[$questionType,$ansString,$ansString]);
$question->{questionType} = $questionType;
}

0 comments on commit 200494b

Please sign in to comment.
You can’t perform that action at this time.