-
Notifications
You must be signed in to change notification settings - Fork 9.4k
M2.1.2 : Impossible to create an after
interceptor when files are being downloaded by controllers
#7356
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
Comments
Hello @kanduvisla, thank you for your submission. We recently made some changes to the way we process GitHub submissions to more quickly identify and respond to core code issues. Your issue is seems Feature Request or Improvement, and they should now be submitted to the new Magento 2 Feature Requests and Improvements forum (see details here). |
I don't see this as a feature request, but rather as a bug. The current way of handling downloads by controllers by directly invoking an |
There is a proposed fix for this #11029. Can you try it and report back? |
@kanduvisla, thank you for your report. |
@kanduvisla thank you for your report. The issue is already fixed in 2.2-develop branch (PR: #11200 by @osrecio) and will be available in the Magento 2.2.2 release |
[Platform Health] Remove PHP8.0 declaration from composer.json
Uh oh!
There was an error while loading. Please reload this page.
Preconditions
Magento - develop branch
Take the
\Magento\Sales\Controller\Adminhtml\Shipment\PrintAction
controller for example. This has anexecute()
-method which triggers a downloading to the browser.Now if you want to do something after this event with a plugin, you're out of luck. Since this controller uses
\Magento\Framework\App\Response\Http\FileFactory::create()
to print the PDF.And if you look closer in this code, you'll notice the following:
This piece if code (especially the
$this->callExit()
) makes it impossible to use a plugin withafter
(oraround
partially), since it hard sends an exit code. That's right:$this->callExit()
is equivalent forexit(0)
.I suggest that this get handles differently because exiting the code in the middle of the Magento lifecycle doesn't seems right to me. Especially if it breaks functionality like this.
Steps to reproduce
Create a plugin that executes code after
\Magento\Sales\Controller\Adminhtml\Shipment\AbstractShipment\PrintAction::execute()
. For example:code:
Expected result
See the 'x' in the browser
Actual result
It just starts downloading; Magento ignores the plugin.
The text was updated successfully, but these errors were encountered: