Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

use ruby time

ulferts76527d46d26e
diff --git a/app/services/journals/create_service.rb b/app/services/journals/create_service.rb
index 4a050e6458d..43ff84ac4cc 100644
--- a/app/services/journals/create_service.rb
+++ b/app/services/journals/create_service.rb
@@ -228,7 +228,7 @@ module Journals
journals
SET
notes = :notes,
- updated_at = #{journal_timestamp_sql(notes, ':updated_at')},
+ updated_at = #{timestamp_sql},
data_id = insert_data.id
FROM insert_data
WHERE journals.id = :predecessor_id
@@ -238,7 +238,6 @@ module Journals
sanitize(journal_sql,
notes: notes.presence || predecessor.notes,
- updated_at: journable_timestamp,
predecessor_id: predecessor.id)
end
@@ -568,10 +567,17 @@ module Journals
if notes.blank? && journable_timestamp
attribute
else
- 'now()'
+ timestamp_sql
end
end
+ def timestamp_sql
+ # Use the ruby time instead of the DB's. If those are out of sync,
+ # a journal might otherwise end up having an updated_at before created_at which
+ # will also reflect back to the journaled object.
+ "'#{Time.zone.now}'"
+ end
+
# Because we added the journal via bare metal sql, rails does not yet
# know of the journal. If the journable has the journals loaded already,
# the caller might expect the journals to also be updated so we do it for him.