-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Improved invoice PDF generation flow #16251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved invoice PDF generation flow #16251
Conversation
Hi @rogyar. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
return $this->_fileFactory->create( | ||
'invoice' . $date . '.pdf', | ||
"invoice_$invoiceId.pdf", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it better to filter $invoiceId
before? I see we are taking it directly from a request.
I am concerned about a potential path traversal attack.
I suppose changing line 51 would be just fine: $invoiceId = (int) $this->getRequest()->getParam('invoice_id');
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Riccardo. That's a very good point. I've added the mentioned change
I am wandering if it does worth to move the focus to
|
@rogyar , I am putting this onhold while we are deciding which is the best way. |
Hi @phoenix128. I'm closing this PR since we have a better solution. I've created another PR for fixing the same issue #16401 . Thanks a lot for the brainstorm! ;) |
Description
Currently, in an attempt to print an invoice from admin panel, the corresponding PDF file is generated directly in
var
directory of the Magento installation. Very often this approach leads to a mess in theva
r directory if the invoice printing action takes place frequently during a day.This PR brings a concept for two improvements:
var/pdf
directory so thevar
directory root is clean.Fixed Issues (if relevant)
Manual testing scenarios
Open an existing invoice in the admin panel.
Click the "Print" button.
You should have the invoice downloaded.
You should have a copy of the invoice generated in the
var/pdf
directory instead ofvar
.Click on the "Print" button once again
The
var/pdf
directory should not contain an additional copy of the same invoiceThe same issue is fare for shipments and credit memos. I'm going to address those parts in a separate PR or within a scope of this one. I just want to make sure that the proposed concept is fine and we are good to move forward.
Thank you