Project

General

Profile

Defect #39079

Updated by Holger Just 10 months ago

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) string results in the following exception: 

 <pre> 
 NoMethodError: undefined method `>' for nil:NilClass 
     app/models/time_entry.rb:187:in `validate_time_entry' 
 </pre> 

 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 version: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.

Back