fixed #10565: Survey: add question doing double-create

This commit is contained in:
Patrick Donelan 2009-06-22 07:08:08 +00:00
parent 3fccab7743
commit b5186bfbab
5 changed files with 79 additions and 31 deletions

View file

@ -1,6 +1,7 @@
7.7.12
- Updated auth to allow sending back of non-text/html mime types.
- fixed #10564: edit branch progress bar goes kablooey
- fixed #10565: Survey: add question doing double-create
7.7.11
- Fixed a bug where empty version tags were not deleted. (Martin Kamerbeek / Oqapi)

View file

@ -22,7 +22,7 @@ use Getopt::Long;
use WebGUI::Session;
use WebGUI::Storage;
use WebGUI::Asset;
use WebGUI::Asset::Wobject::Survey;
my $toVersion = '7.7.12';
my $quiet; # this line required
@ -31,6 +31,7 @@ my $quiet; # this line required
my $session = start(); # this line required
# upgrade functions go here
surveyCleanUp($session);
finish($session); # this line required
@ -44,6 +45,38 @@ finish($session); # this line required
# print "DONE!\n" unless $quiet;
#}
#----------------------------------------------------------------------------
sub surveyCleanUp {
my $session = shift;
print "\tRemoving extra properties that may have crept into surveyJSON... " unless $quiet;
my $sth = $session->db->read('select assetId, revisionDate from Survey');
while (my ($assetId, $revision) = $sth->array) {
my $survey = WebGUI::Asset->new($session, $assetId, 'WebGUI::Asset::Wobject::Survey', $revision);
# Remove recursive properties that snuck into the mold
if (my $mold = $survey->surveyJSON->mold) {
$mold->{question}{answers} = [];
$mold->{section}{questions} = [];
}
# Remove keys that should never have been added to sections/questions/answers
for my $s (@{$survey->surveyJSON->sections}) {
for my $q (@{$s->{questions} || []}) {
for my $a (@{$q->{answers} || []}) {
delete $a->{$_} for qw(delete copy removetype addtype func);
}
delete $q->{$_} for qw(delete copy removetype addtype func);
}
delete $s->{$_} for qw(delete copy removetype addtype func);
}
$survey->persistSurveyJSON;
}
print "DONE!\n" unless $quiet;
}
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------