[LON-CAPA-cvs] cvs: loncom /interface loncoursedata.pm
matthew
lon-capa-cvs@mail.lon-capa.org
Thu, 19 Jun 2003 12:45:54 -0000
matthew Thu Jun 19 08:45:54 2003 EDT
Modified files:
/loncom/interface loncoursedata.pm
Log:
Bug 1497 - random crashes in spreadsheet caused by loncoursedata.pm.
The error was due to some unexpected return data being passed to
&get_current_state from &ensure_current_data. Now explicitly return
undef for the second parameter if appropriate. Extra code has been put in
&get_current_state to prevent it from trying to cast undef as a hash.
Index: loncom/interface/loncoursedata.pm
diff -u loncom/interface/loncoursedata.pm:1.78 loncom/interface/loncoursedata.pm:1.79
--- loncom/interface/loncoursedata.pm:1.78 Tue Jun 17 17:45:36 2003
+++ loncom/interface/loncoursedata.pm Thu Jun 19 08:45:54 2003
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: loncoursedata.pm,v 1.78 2003/06/17 21:45:36 matthew Exp $
+# $Id: loncoursedata.pm,v 1.79 2003/06/19 12:45:54 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -916,7 +916,7 @@
$sname.':'.$sdom.' in course '.$courseid.
':'.$tmp[0]);
$returnstatus = 'error getting data';
- return $returnstatus;
+ return ($returnstatus,undef);
}
if (scalar(@tmp) < 1) {
return ('no data',undef);
@@ -940,7 +940,7 @@
my $num_parameters = 0;
my $store_performance_command = 'INSERT INTO '.$performance_table.
' VALUES '."\n";
- return 'error' if (! defined($dbh));
+ return ('error',undef) if (! defined($dbh));
while (my ($current_symb,$param_hash) = each(%student_data)) {
#
# make sure the symb is set up properly
@@ -994,14 +994,14 @@
&Apache::lonnet::logthis(' bigass insert error:'.$dbh->errstr());
&Apache::lonnet::logthis('command = '.$store_parameters_command);
$returnstatus = 'error: unable to insert parameters into database';
- return $returnstatus,\%student_data;
+ return ($returnstatus,\%student_data);
}
$dbh->do($store_performance_command);
if ($dbh->err()) {
&Apache::lonnet::logthis(' bigass insert error:'.$dbh->errstr());
&Apache::lonnet::logthis('command = '.$store_performance_command);
$returnstatus = 'error: unable to insert performance into database';
- return $returnstatus,\%student_data;
+ return ($returnstatus,\%student_data);
}
$elapsed += Time::HiRes::time - $start;
#
@@ -1057,7 +1057,7 @@
!$found_student || !$found_part ||
!$found_performance || !$found_parameters) {
if (&init_dbs($courseid)) {
- return 'error';
+ return ('error',undef);
}
}
#
@@ -1225,13 +1225,12 @@
# }
# }
#
- if (defined($data)) {
- if (defined($symb)) {
- return %{$data->{$symb}};
- } else {
- return %$data;
- }
- } elsif ($status eq 'no data') {
+ if (defined($data) && defined($symb) && ref($data->{$symb})) {
+ return %{$data->{$symb}};
+ } elsif (defined($data) && ! defined($symb) && ref($data)) {
+ return %$data;
+ }
+ if ($status eq 'no data') {
return ();
} else {
if ($status ne 'okay' && $status ne '') {