@@ -1340,9 +1340,7 @@ sub upgrade_course_confirm ($c) {
1340
1340
1341
1341
# Report on database status
1342
1342
my ($tables_ok , $dbStatus ) = $CIchecker -> checkCourseTables($upgrade_courseID );
1343
- my ($all_tables_ok , $extra_database_tables , $extra_database_fields , $rebuild_table_indexes ,
1344
- $incorrect_type_database_fields , $db_report )
1345
- = $c -> formatReportOnDatabaseTables($dbStatus , $upgrade_courseID );
1343
+ my $dbReport = $c -> formatReportOnDatabaseTables($dbStatus , $upgrade_courseID );
1346
1344
1347
1345
my $course_output = $c -> c;
1348
1346
@@ -1368,9 +1366,9 @@ sub upgrade_course_confirm ($c) {
1368
1366
);
1369
1367
push (@$course_output , $c -> tag(' h2' , $c -> maketext(' Report for course [_1]:' , $upgrade_courseID )));
1370
1368
push (@$course_output , $c -> tag(' div' , class => ' mb-2' , $c -> maketext(' Database:' )));
1371
- push (@$course_output , $db_report );
1369
+ push (@$course_output , $dbReport -> { summary } );
1372
1370
1373
- if ($extra_database_tables ) {
1371
+ if ($dbReport -> { extra_database_tables } ) {
1374
1372
$extra_database_tables_exist = 1;
1375
1373
push (
1376
1374
@$course_output ,
@@ -1384,7 +1382,7 @@ sub upgrade_course_confirm ($c) {
1384
1382
);
1385
1383
}
1386
1384
1387
- if ($extra_database_fields ) {
1385
+ if ($dbReport -> { extra_database_fields } ) {
1388
1386
$extra_database_fields_exist = 1;
1389
1387
push (
1390
1388
@$course_output ,
@@ -1400,7 +1398,7 @@ sub upgrade_course_confirm ($c) {
1400
1398
);
1401
1399
}
1402
1400
1403
- if ($rebuild_table_indexes ) {
1401
+ if ($dbReport -> { rebuild_table_indexes } ) {
1404
1402
push (
1405
1403
@$course_output ,
1406
1404
$c -> tag(
@@ -1415,7 +1413,7 @@ sub upgrade_course_confirm ($c) {
1415
1413
);
1416
1414
}
1417
1415
1418
- if ($incorrect_type_database_fields ) {
1416
+ if ($dbReport -> { incorrect_type_database_fields } ) {
1419
1417
$incorrect_type_database_fields_exist = 1;
1420
1418
push (
1421
1419
@$course_output ,
@@ -1547,15 +1545,13 @@ sub do_upgrade_course ($c) {
1547
1545
# Analyze database status and prepare status report
1548
1546
($tables_ok , $dbStatus ) = $CIchecker -> checkCourseTables($upgrade_courseID );
1549
1547
1550
- my ($all_tables_ok , $extra_database_tables , $extra_database_fields , $rebuild_table_indexes ,
1551
- $incorrect_type_database_fields , $db_report )
1552
- = $c -> formatReportOnDatabaseTables($dbStatus );
1548
+ my $dbReport = $c -> formatReportOnDatabaseTables($dbStatus );
1553
1549
1554
1550
# Prepend course name
1555
- $db_report = $c -> c($c -> tag(' div' , class => ' mb-2' , $c -> maketext(' Database:' )), $db_report );
1551
+ my $db_report = $c -> c($c -> tag(' div' , class => ' mb-2' , $c -> maketext(' Database:' )), $dbReport -> { summary } );
1556
1552
1557
1553
# Report on databases and report summary
1558
- if ($extra_database_tables ) {
1554
+ if ($dbReport -> { extra_database_tables } ) {
1559
1555
push (
1560
1556
@$db_report ,
1561
1557
$c -> tag(
@@ -1565,7 +1561,7 @@ sub do_upgrade_course ($c) {
1565
1561
)
1566
1562
);
1567
1563
}
1568
- if ($extra_database_fields ) {
1564
+ if ($dbReport -> { extra_database_fields } ) {
1569
1565
push (
1570
1566
@$db_report ,
1571
1567
$c -> tag(
@@ -1577,7 +1573,7 @@ sub do_upgrade_course ($c) {
1577
1573
);
1578
1574
}
1579
1575
1580
- if ($incorrect_type_database_fields ) {
1576
+ if ($dbReport -> { incorrect_type_database_fields } ) {
1581
1577
push (
1582
1578
@$db_report ,
1583
1579
$c -> tag(
@@ -2785,13 +2781,14 @@ sub formatReportOnDatabaseTables ($c, $dbStatus, $courseID = undef) {
2785
2781
)
2786
2782
);
2787
2783
2788
- my $all_tables_ok = 1;
2789
- my $extra_database_tables = 0;
2790
- my $extra_database_fields = 0;
2791
- my $rebuild_table_indexes = 0;
2792
- my $incorrect_type_database_fields = 0;
2793
-
2794
- my $db_report = $c -> c;
2784
+ my $dbReport = {
2785
+ all_tables_ok => 1,
2786
+ extra_database_tables => 0,
2787
+ extra_database_fields => 0,
2788
+ rebuild_table_indexes => 0,
2789
+ incorrect_type_database_fields => 0,
2790
+ summary => $c -> c
2791
+ };
2795
2792
2796
2793
for my $table (sort keys %$dbStatus ) {
2797
2794
my $table_report = $c -> c;
@@ -2800,9 +2797,9 @@ sub formatReportOnDatabaseTables ($c, $dbStatus, $courseID = undef) {
2800
2797
push (@$table_report , $table . ' : ' , $table_status_message {$table_status });
2801
2798
2802
2799
if ($table_status == WeBWorK::Utils::CourseDBIntegrityCheck::ONLY_IN_A) {
2803
- $all_tables_ok = 0;
2800
+ $dbReport -> { all_tables_ok } = 0;
2804
2801
} elsif ($table_status == WeBWorK::Utils::CourseDBIntegrityCheck::ONLY_IN_B) {
2805
- $extra_database_tables = 1;
2802
+ $dbReport -> { extra_database_tables } = 1;
2806
2803
push (
2807
2804
@$table_report ,
2808
2805
$c -> tag(
@@ -2826,9 +2823,9 @@ sub formatReportOnDatabaseTables ($c, $dbStatus, $courseID = undef) {
2826
2823
2827
2824
if ($field_status == WeBWorK::Utils::CourseDBIntegrityCheck::ONLY_IN_B) {
2828
2825
if ($fieldInfo {$key }[1]) {
2829
- $rebuild_table_indexes = 1;
2826
+ $dbReport -> { rebuild_table_indexes } = 1;
2830
2827
} else {
2831
- $extra_database_fields = 1;
2828
+ $dbReport -> { extra_database_fields } = 1;
2832
2829
}
2833
2830
if (defined $courseID ) {
2834
2831
if ($fieldInfo {$key }[1]) {
@@ -2855,9 +2852,9 @@ sub formatReportOnDatabaseTables ($c, $dbStatus, $courseID = undef) {
2855
2852
}
2856
2853
}
2857
2854
} elsif ($field_status == WeBWorK::Utils::CourseDBIntegrityCheck::ONLY_IN_A) {
2858
- $all_tables_ok = 0;
2855
+ $dbReport -> { all_tables_ok } = 0;
2859
2856
} elsif ($field_status == WeBWorK::Utils::CourseDBIntegrityCheck::DIFFER_IN_A_AND_B) {
2860
- $incorrect_type_database_fields = 1;
2857
+ $dbReport -> { incorrect_type_database_fields } = 1;
2861
2858
if (defined $courseID ) {
2862
2859
push (
2863
2860
@$field_report ,
@@ -2887,18 +2884,17 @@ sub formatReportOnDatabaseTables ($c, $dbStatus, $courseID = undef) {
2887
2884
}
2888
2885
push (@$table_report , $c -> tag(' ul' , $fields_report -> join (' ' )));
2889
2886
}
2890
- push (@$db_report , $c -> tag(' li' , $table_report -> join (' ' )));
2887
+ push (@{ $dbReport -> { summary } } , $c -> tag(' li' , $table_report -> join (' ' )));
2891
2888
}
2892
2889
2893
- $db_report = $c -> c($c -> tag(' ul' , $db_report -> join (' ' )));
2890
+ $dbReport -> { summary } = $c -> c($c -> tag(' ul' , $dbReport -> { summary } -> join (' ' )));
2894
2891
2895
- push (@$db_report , $c -> tag(' p' , class => ' text-success' , $c -> maketext(' Database tables are ok' ))) if $all_tables_ok ;
2892
+ push (@{ $dbReport -> {summary } }, $c -> tag(' p' , class => ' text-success' , $c -> maketext(' Database tables are ok' )))
2893
+ if $dbReport -> {all_tables_ok };
2896
2894
2897
- return (
2898
- $all_tables_ok , $extra_database_tables , $extra_database_fields , $rebuild_table_indexes ,
2899
- $incorrect_type_database_fields ,
2900
- $db_report -> join (' ' )
2901
- );
2895
+ $dbReport -> {summary } = $dbReport -> {summary }-> join (' ' );
2896
+
2897
+ return $dbReport ;
2902
2898
}
2903
2899
2904
2900
1;
0 commit comments