summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2018-10-06 13:10:22 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2018-10-06 13:10:22 +0000
commit323ef3182bc45184c7a14e3a8dc7244850baabed (patch)
tree25b170577bc22219638bde0663f1a629c5e5eb42
parent5416ed10222c82fbb1167377f0c7cb49e58ef4d7 (diff)
downloadredmine-323ef3182bc45184c7a14e3a8dc7244850baabed.tar.gz
redmine-323ef3182bc45184c7a14e3a8dc7244850baabed.zip
Ensure that ActiveRecord::Base objects are fully serialized for mail sending (#26791).
Patch by Holger Just. git-svn-id: http://svn.redmine.org/redmine/trunk@17585 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/mailer.rb39
1 files changed, 38 insertions, 1 deletions
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index 4427d333d..ab1a6cf4c 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -107,11 +107,48 @@ class Mailer < ActionMailer::Base
"method*, or 3. use a custom Active Job instead of #deliver_later."
else
args = 'Mailer', @action.to_s, delivery_method.to_s, *@args
- ::ActionMailer::DeliveryJob.set(options).perform_later(*args)
+ DeliveryJob.set(options).perform_later(*args)
end
end
end
+ class DeliveryJob < ActionMailer::DeliveryJob
+ module Arguments
+ extend ActiveJob::Arguments
+ extend self
+
+ private
+
+ def serialize_argument(argument)
+ # Ensure that ActiveRecord::Base objects are fully serialized for mail
+ # sending. This circumvents the globalid gem for this job.
+ if argument.is_a?(ActiveRecord::Base)
+ argument.to_yaml
+ else
+ super
+ end
+ end
+
+ def deserialize_argument(argument)
+ if argument.is_a?(ActiveRecord::Base)
+ argument
+ else
+ super
+ end
+ end
+ end
+
+ private
+
+ def serialize_arguments(serialized_args)
+ Arguments.serialize(serialized_args)
+ end
+
+ def deserialize_arguments(serialized_args)
+ Arguments.deserialize(serialized_args)
+ end
+ end
+
def process(action, *args)
user = args.shift
raise ArgumentError, "First argument has to be a user, was #{user.inspect}" unless user.is_a?(User)