Bug 19328: Internal server error because of missing currency
authorMarc Véron <veron@veron.ch>
Sun, 17 Sep 2017 09:53:34 +0000 (11:53 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 11 Oct 2017 16:05:31 +0000 (13:05 -0300)
This patch fixes internal server errors because of missing active currency
in files aqbudgetperiods.pl, aqbudgets.pl and aqplan.pl.

To reproduce:
- Make sure that no active currency is defined. You can undefine the active
  currency in Administration->Currencies and exchange rates
- Try to go to Administration->Budgets and Admistration->Funds
Result: Internal server error

To test:
- Apply patch
- Restart plack
- Try to reproduce issue, it should no longer occur. There should be a
  yellow message box "No active currency is defined"
- From Administration-> Budgets administration try to edit a fund and go to
  "Planning". Verify that the message box appears here as well.

Signed-off-by: David Bourgault <david.bourgault@inlibro.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
admin/aqbudgetperiods.pl
admin/aqbudgets.pl
admin/aqplan.pl

index fbe1938..0a05a55 100755 (executable)
@@ -91,9 +91,11 @@ my ($template, $borrowernumber, $cookie, $staff_flags ) = get_template_and_user(
 
 # This is used in incbudgets-active-currency.inc
 my $active_currency = Koha::Acquisition::Currencies->get_active;
-$template->param( symbol => $active_currency->symbol,
-                  currency => $active_currency->currency
-               );
+if ( $active_currency ) {
+    $template->param( symbol => $active_currency->symbol,
+                      currency => $active_currency->currency
+                   );
+}
 
 # ADD OR MODIFY A BUDGET PERIOD - BUILD SCREEN
 if ( $op eq 'add_form' ) {
index 7e85254..f106a86 100755 (executable)
@@ -50,9 +50,11 @@ my ($template, $borrowernumber, $cookie, $staffflags ) = get_template_and_user(
 );
 
 my $active_currency = Koha::Acquisition::Currencies->get_active;
-$template->param( symbol => $active_currency->symbol,
-                  currency => $active_currency->currency
-               );
+if ( $active_currency ) {
+    $template->param( symbol => $active_currency->symbol,
+                      currency => $active_currency->currency
+                   );
+}
 
 my $op = $input->param('op') || 'list';
 
index a27fb0a..f96086e 100755 (executable)
@@ -58,9 +58,11 @@ my $budget_period_id = $input->param('budget_period_id');
 my $period = GetBudgetPeriod($budget_period_id);
 my $count  = GetPeriodsCount();
 my $active_currency = Koha::Acquisition::Currencies->get_active;
-$template->param( symbol => $active_currency->symbol,
-                  currency => $active_currency->currency,
-               );
+if ( $active_currency ) {
+    $template->param( symbol => $active_currency->symbol,
+                      currency => $active_currency->currency,
+                   );
+}
 $template->param( period_button_only => 1 ) if $count == 0;