Bug 18774

Summary: Internal Server Error in Price.pm with big numbers
Product: Koha Reporter: Marc Véron <veron>
Component: Architecture, internals, and plumbingAssignee: Bugs List <koha-bugs>
Status: RESOLVED DUPLICATE QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: jonathan.druart
Version: master   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15770
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17164
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11698
Whiteboard:
Change sponsored?: --- Patch complexity: ---
Bot Control: --- When did the bot last check this:
Who signed the patch off: Text to go in the release notes:
Bug Depends on: 12844    
Bug Blocks:    
Attachments: Bug 18774: Add test to highlight problem with Internal Server Error in Price.pm
Bug 18774: Add test for Price.pm

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 ***