Don't dump massive binary PDF data into the job queue

Here we were rendering an entire PDF, then passing that PDF into the job queue as an *argument* containing the entire binary of the PDF in a massive string. This means the job object itself would contain that entire PDF. That's bad queueing!

We now create the PDF *during* the job (not before it), and pass simple arguments.
This commit is contained in:
Matt-Yorkley
2021-05-29 15:44:00 +01:00
parent 0d95d83ef9
commit 834140f0a2
2 changed files with 4 additions and 4 deletions

View File

@@ -81,9 +81,7 @@ module Spree
end
def invoice
pdf = InvoiceRenderer.new.render_to_string(@order)
Spree::OrderMailer.invoice_email(@order.id, pdf).deliver_later
Spree::OrderMailer.invoice_email(@order.id).deliver_later
flash[:success] = t('admin.orders.invoice_email_sent')
respond_with(@order) { |format|

View File

@@ -49,8 +49,10 @@ module Spree
end
end
def invoice_email(order_or_order_id, pdf)
def invoice_email(order_or_order_id)
@order = find_order(order_or_order_id)
pdf = InvoiceRenderer.new.render_to_string(@order)
attach_file("invoice-#{@order.number}.pdf", pdf)
I18n.with_locale valid_locale(@order.user) do
mail(to: @order.email,