Bug 18774 - Internal Server Error in Price.pm with big numbers
Summary: Internal Server Error in Price.pm with big numbers
Status: RESOLVED DUPLICATE of bug 15770
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low major (vote)
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on: 12844
Blocks:
  Show dependency treegraph
 
Reported: 2017-06-10 06:05 UTC by Marc Véron
Modified: 2017-06-19 21:51 UTC (History)
1 user (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 18774: Add test to highlight problem with Internal Server Error in Price.pm (1.37 KB, patch)
2017-06-10 06:19 UTC, Marc Véron
Details | Diff | Splinter Review
Bug 18774: Add test for Price.pm (1.43 KB, patch)
2017-06-11 20:34 UTC, Lee Jamison
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Véron 2017-06-10 06:05:32 UTC
If users accidentally enter a big number e.g. in Home > Patrons > Manual invoice, Koha fails with an Internal Server Error in Price.pm

To reproduce, enter a value of: 99999999999999

Plack error log says:
Template process failed: undef error - round() overflow. Try smaller precision or use Math::BigFloat at /home/marc/koha/Koha/Number/Price.pm line 44.

After that error, the detail page of the user where the invoice was applied can no longer be displayed, it produces the same Internal Server Error

This is due to the fact that the big number is stored in table accountlines.

Setting to major because normal users can not recover from this situation.

To recover, you have to delete or update the records in table accountlines.

The same error can be produced with a manual credit.

The same error can occur in Administration > Patron Categories if the numbers in the database are too big, see
http://irc.koha-community.org/koha/2017-06-09#i_1942793
...but it can not be reproduced by entering a big number. Biggest number you can enter is: 99999999
Comment 1 Marc Véron 2017-06-10 06:19:07 UTC
Created attachment 64171 [details] [review]
Bug 18774: Add test to highlight problem with Internal Server Error in Price.pm

Add a test for a big number to t/Number/Price.t

Test will fail with:
round() overflow. Try smaller precision or use Math::BigFloat at
(...)/Koha/Number/Price.pm line 44.
Comment 2 Lee Jamison 2017-06-11 20:34:09 UTC
Created attachment 64188 [details] [review]
Bug 18774: Add test for Price.pm

Add a test for a big number to t/Number/Price.t

Test will fail with:
round() overflow. Try smaller precision or use Math::BigFloat at
(...)/Koha/Number/Price.pm line 44.

Signed-off-by: Lee Jamison <ldjamison@marywood.edu>
Test failure occurs as described. This patch passes QA tools.
Still in need of a patch for the problem itself but the patch
works as described.
Comment 3 Marc Véron 2017-06-12 05:14:50 UTC
How to fix? - The problem occurs at other places as well (see related bugs).

A first step could be to restrict amount users can enter, similar to the situation in Administration > Patron Categories, but theoretically fines and/or credits (and budgets etc., see Bug 11698) can sum up to a value that breaks display again.

Where amounts are added, the fix could be to have a JavaScript validation against the sum, but it would be a workaround only, see following comment:
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11698#c2
Comment 4 Jonathan Druart 2017-06-19 21:51:39 UTC

*** This bug has been marked as a duplicate of bug 15770 ***