Actions
Defect #39079
closedNoMethodError when trying to remove the date of an existing time entry
Start date:
Due date:
% Done:
0%
Estimated time:
Resolution:
Fixed
Affected version:
Description
Given
- an existing time entry
Setting.timelog_accept_future_dates?
is disabled
then editing the time entry to remove the spent_on
field (i.e. setting it to nil
or an empty string) results in the following exception:
NoMethodError: undefined method `>' for nil:NilClass app/models/time_entry.rb:187:in `validate_time_entry'
Here, it is assumed that the spent_on
value is always present as validated by the validates_presence_of :spent_on
. During validations however, this may not always be the case as Rails always runs all validations, regardless of any prior failing validations. The issue was originally introduced in #3322, first released with 4.1.0.
The attached patch fixes this error by only checking the spent_on
value in validate_time_entry
if it was provided. If it is missing or is wrongly formatted, the other validations will catch this and still reject to save the model.
Files
Updated by Go MAEDA about 1 year ago
- Status changed from New to Confirmed
- Target version set to 4.2.11
Updated by Go MAEDA about 1 year ago
- Status changed from Confirmed to Closed
- Assignee set to Go MAEDA
- Resolution set to Fixed
Committed the fix. Thank you.
Actions