Bug 19328 - Internal server error because of missing currency
Summary: Internal server error because of missing currency
Status: Pushed to Master
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Marc Véron
QA Contact: Testopia
URL:
Whiteboard:
Keywords:
Depends on: 15084
Blocks:
  Show dependency treegraph
 
Reported: 2017-09-15 21:15 UTC by Michael Kuhn
Modified: 2017-10-11 16:54 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
Bug 19328 - Internal server error because of missing currency (3.16 KB, patch)
2017-09-17 10:04 UTC, Marc Véron
Details | Diff | Splinter Review
Bug 19328 - Internal server error because of missing currency (3.22 KB, patch)
2017-09-22 17:56 UTC, David Bourgault
Details | Diff | Splinter Review
Bug 19328 - Internal server error because of missing currency (3.28 KB, patch)
2017-10-11 00:35 UTC, Nick Clemens
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Kuhn 2017-09-15 21:15:52 UTC
When clicking "Budgets" or "Funds" in Koha menu "Administration > Acquisition parameters" just a blank page does appear, saying "Internal server error".

When clicking "Budgets" the log file "plack-error.log" says:

Can't call method "symbol" on an undefined value at /usr/share/koha/intranet/cgi-bin/admin/aqbudgetperiods.pl line 94.

When clicking "Funds" it says:

Can't call method "symbol" on an undefined value at /usr/share/koha/intranet/cgi-bin/admin/aqbudgets.pl line 53.

For example, line 94 of script "aqbudgetperiods.pl" says:

$template->param( symbol => $active_currency->symbol,
                  currency => $active_currency->currency 

So this happens when no activated currency exists (for example when no example currency was loaded). Instead of showing "Internal Server Error" Koha should tell about the missing activated currency.

This was experienced in Koha 16.11.1 as well as in Koha 17.05.1.
Comment 1 Marc Véron 2017-09-17 10:03:52 UTC
Confirmed on current master.
Comment 2 Marc Véron 2017-09-17 10:04:44 UTC
Created attachment 67179 [details] [review]
Bug 19328 - Internal server error because of missing currency

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.
Comment 3 Marc Véron 2017-09-17 10:18:32 UTC
Seems to be a regression.

Oh, there are more candidates for Internal server errors, maybe to be investigated / fixed in a separate bug:

git grep 'Currencies->get_active'

C4/Biblio.pm:    my $active_currency = Koha::Acquisition::Currencies->get_active;
C4/Overdues.pm:    my $active_currency = Koha::Acquisition::Currencies->get_active;
Koha/Number/Price.pm:    my $currency        = Koha::Acquisition::Currencies->get_active;
about.pl:my $warnNoActiveCurrency = (! defined Koha::Acquisition::Currencies->get_active);
acqui/acqui-home.pl:my $cur = Koha::Acquisition::Currencies->get_active;
acqui/addorder.pl:            my $currency = Koha::Acquisition::Currencies->get_active;
acqui/addorderiso2709.pl:    my $active_currency = Koha::Acquisition::Currencies->get_active;
acqui/basket.pl:    my $active_currency = Koha::Acquisition::Currencies->get_active;
acqui/invoice.pl:    currency         => Koha::Acquisition::Currencies->get_active,
acqui/neworderempty.pl:my $active_currency = Koha::Acquisition::Currencies->get_active;
admin/aqbudgetperiods.pl:my $active_currency = Koha::Acquisition::Currencies->get_active;
admin/aqbudgets.pl:my $active_currency = Koha::Acquisition::Currencies->get_active;
admin/aqplan.pl:my $active_currency = Koha::Acquisition::Currencies->get_active;
admin/preferences.pl:    my $active_currency = Koha::Acquisition::Currencies->get_active;
opac/opac-account-pay-paypal-return.pl:my $active_currency = Koha::Acquisition::Currencies->get_active;
opac/opac-account-pay.pl:my $active_currency = Koha::Acquisition::Currencies->get_active;
opac/sco/sco-main.pl:if ( my $active_currency = Koha::Acquisition::Currencies->get_active ) {
t/db_dependent/Koha/Acquisition/Currencies.t:my $active_currency = Koha::Acquisition::Currencies->get_active;
t/db_dependent/MungeMarcPrice.t:my $active_currency = Koha::Acquisition::Currencies->get_active;
Comment 4 David Bourgault 2017-09-22 17:56:07 UTC
Created attachment 67321 [details] [review]
Bug 19328 - Internal server error because of missing currency

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>
Comment 5 Nick Clemens 2017-10-11 00:35:26 UTC
Created attachment 67922 [details] [review]
Bug 19328 - Internal server error because of missing currency

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>
Comment 6 Jonathan Druart 2017-10-11 15:44:31 UTC
I am willing to push this patch but I do not think it is the way to fix it.

Please do not fix more occurrences.
Comment 7 Jonathan Druart 2017-10-11 16:54:29 UTC
Pushed to master for 17.11, thanks to everybody involved!