Wrong calculation numeric commentsfield

Post Reply
dwedwin
Posts: 8
Joined: 08 Feb 2021, 14:23
Name: Edwin
Location: Amsterdam

Wrong calculation numeric commentsfield

Post by dwedwin »

Hi,

The calculation after submitting values in the comments form is not correct.
When saving the record the numbers are calculated correctly.

Video: https://drive.google.com/file/d/1ZAeOpt ... sp=sharing
User avatar
support
Site Admin
Posts: 6222
Joined: 19 Oct 2014, 18:22
Name: Sergey Kharchishin
Location: Russia, Evpatoriya

Re: Wrong calculation numeric commentsfield

Post by support »

Sorry, can't reproduce it on my account.
Try to go to phpmyadmin and change field type to FLOAT for these fields.
dwedwin
Posts: 8
Joined: 08 Feb 2021, 14:23
Name: Edwin
Location: Amsterdam

Re: Wrong calculation numeric commentsfield

Post by dwedwin »

Unfortunately the problem persists after changing the field type.
Interestingly enough, the calculation is performed correctly when I edit and save the entity. Only when placing a comment it does not work properly.
User avatar
support
Site Admin
Posts: 6222
Joined: 19 Oct 2014, 18:22
Name: Sergey Kharchishin
Location: Russia, Evpatoriya

Re: Wrong calculation numeric commentsfield

Post by support »

Can you send me backup of your database to check in PM?
dwedwin
Posts: 8
Joined: 08 Feb 2021, 14:23
Name: Edwin
Location: Amsterdam

Re: Wrong calculation numeric commentsfield

Post by dwedwin »

I am a new user to the forum and unfortunately cannot send private messages.

Edit: After this message, it was possible. The message has been sent!
dwedwin
Posts: 8
Joined: 08 Feb 2021, 14:23
Name: Edwin
Location: Amsterdam

Re: Wrong calculation numeric commentsfield

Post by dwedwin »

I found the problem. The system locale on my server was set to nl_NL. The default decimal separator in the Netherlands is a comma (,).
After calculating the new value (/modules/items/actions/comments.php, line #126) it was stored in the database with a comma (e.g. 7,15).

Setting the locale to en_US solved the problem. But perhaps it would be wise to catch this in the code as well.

Thanks for the help!
User avatar
support
Site Admin
Posts: 6222
Joined: 19 Oct 2014, 18:22
Name: Sergey Kharchishin
Location: Russia, Evpatoriya

Re: Wrong calculation numeric commentsfield

Post by support »

This is something unusual. Function get_fields_sum return sum of numbers without formating so there is no bug in code.
Post Reply