Error thrown dividing a result from a date using a mathematical field
- Status
- Closed
- Subject
- Error thrown dividing a result from a date using a mathematical field
- Version
- 20.x
21.x - Category
- Regression
- Feature
- Trackers
- Resolution status
- Confirmed
- Submitted by
- Bernard Sfez / Tiki Specialist
- Volunteered to solve
- Jonny Bradley
- Keep informed
- Victor Emanouilov
- Lastmod by
- Bernard Sfez / Tiki Specialist
- Rating
- Related-to
- Description
When using a mathematical field I created several times in the past a field to calculate the age of someone using:
Copy to clipboard(round (div (sub (date) childrenBirthDate) 31536000 ) 1)
In Tiki 20.1 (from Git; no revision number found) it thrown an error:Divide by zero on "0"
Copy to clipboard(sub (date) childrenBirthDate)is not throwing the error.
The error is coming from a test at "lib/core/Math/Formula/Function/Div.php".
Updated 04/04/2020
After upgrading to Tiki21 the workaround is not useable anymore.
It forbid the index rebuilt operation to complete and therefore the Tiki is broken.
See: https://dev.tiki.org/item7304-Change-in-condition-inside-a-calculation-field-breaks-rebuilt-index-operation-and-calculation
Update 20/05/2020
Found the culprit ! (and it is not directly related to calculation ?)
I have in this tracker an item list field that get info from another tracker so I need to use trackerrender to display the original value and not the value of the dropdown item.
It is not used for any calculation, it is the employee ID
To display it I use:Copy to clipboard{FORMAT(name="id")}{display name="tracker_field_timeworkEmployeeId" format="trackerrender" default=""}{FORMAT}Used that way I got the error:
Divide by zero on "0"
If I change the format for:Copy to clipboard{FORMAT(name="id")}{display name="tracker_field_timeworkEmployeeId_text" default=""}{FORMAT}
The error is gone.- Solution
Seems fixed under Tiki22.
May be a backport ?- Workaround
Do you have relation fields in the same tracker? Or pointing to it? Seems that it tries to run the same formula on other trackers without the references field i think when it's trying to do
tracker_refresh_itemslist_detailbut i got lost trying to debug it... (hence adding Victor to this wish)The workaround I did was to add an
ifaround it (which I think is good practice anyway), e.g.Copy to clipboard(if childrenBirthDate (round (div (sub (date) childrenBirthDate) 31536000 ) 1))- Importance
- 5
- Easy to solve?
- 5
- Priority
- 25
- Demonstrate Bug on Tiki 19+
-
This bug has been demonstrated on show2.tiki.org
Please demonstrate your bug on show2.tiki.org
Show.tiki.org is not configured properlyThe public/private keys configured to connect to show2.tiki.org were not accepted. Please make sure you are using RSA keys. Thanks.
- Demonstrate Bug (older Tiki versions)
-
This bug has been demonstrated on show.tikiwiki.org
Please demonstrate your bug on show.tikiwiki.org
Show.tiki.org is not configured properlyThe public/private keys configured to connect to show.tikiwiki.org were not accepted. Please make sure you are using RSA keys. Thanks.
- Ticket ID
- 7165
- Created
- Monday 26 August, 2019 15:49:15 UTC
by Bernard Sfez / Tiki Specialist - LastModif
- Sunday 04 July, 2021 11:41:13 UTC