-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Backport of MAGETWO-71545 for Magento 2.1: Added 'application/json' C… #13548
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
Conversation
…ontent-Type to Ajax responses in the Magento_UI module. magento#10521 (cherry picked from commit ddfc01e)
a144102
to
861ca5e
Compare
I'll have a look at fixing the tests later today probably. |
861ca5e
to
15405c3
Compare
I've fixed the static test failure, but I failed at fixing the unit tests, it's because
Any help with fixing the unit tests would be appreciated! My PHPUnit skills are almost non-existing, so yeah ... :) |
Try something like:
|
15405c3
to
245058d
Compare
Unit tests should be fixed now (on my local machine at least). Would be great if someone can review if they are fixed correctly, see my second commit. Thanks! |
245058d
to
5257492
Compare
Hi @hostep would you be able to look through the conflicts in this PR so we can process this? Thanks |
Hi @dmanners, the conflicts originate from changes introduced in Magento 2.1.12, which are also introduced in 2.2.3 (I find very little information in the commit messages as to why the changes were added: "MAGETWO-84847: Prepare codebase for 2.1.12" doesn't give me a lot of useful information to be honest). I'm going to hold of on fixing this, because I want to see how these security related changes are going to be forward ported to Just FYI, I started fixing the conflicts, and fixed the conflict in diff --git a/app/code/Magento/Ui/Controller/Adminhtml/Index/Render.php b/app/code/Magento/Ui/Controller/Adminhtml/Index/Render.php
index e16e3e43bdf..0523a5c40ed 100644
--- a/app/code/Magento/Ui/Controller/Adminhtml/Index/Render.php
+++ b/app/code/Magento/Ui/Controller/Adminhtml/Index/Render.php
@@ -9,12 +9,32 @@ use Magento\Backend\App\Action\Context;
use Magento\Ui\Controller\Adminhtml\AbstractAction;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Framework\View\Element\UiComponentInterface;
+use Magento\Ui\Model\UiComponentTypeResolver;
/**
* Class Render
*/
class Render extends AbstractAction
{
+ /**
+ * @var \Magento\Ui\Model\UiComponentTypeResolver
+ */
+ private $contentTypeResolver;
+
+ /**
+ * @param Context $context
+ * @param UiComponentFactory $factory
+ * @param UiComponentTypeResolver $contentTypeResolver
+ */
+ public function __construct(
+ Context $context,
+ UiComponentFactory $factory,
+ UiComponentTypeResolver $contentTypeResolver
+ ) {
+ parent::__construct($context, $factory);
+ $this->contentTypeResolver = $contentTypeResolver;
+ }
+
/**
* Action for AJAX request
*
@@ -27,7 +47,7 @@ class Render extends AbstractAction
return;
}
- $component = $this->factory->create($this->_request->getParam('namespace'));
+ $component = $this->factory->create($this->getRequest()->getParam('namespace'));
$aclResource = $component->getData('acl');
@@ -38,11 +58,10 @@ class Render extends AbstractAction
$this->prepareComponent($component);
- if ($component->getContext()->getAcceptType() === 'json') {
- $this->_response->setHeader('Content-Type', 'application/json');
- }
+ $this->getResponse()->appendBody((string) $component->render());
- $this->_response->appendBody((string) $component->render());
+ $contentType = $this->contentTypeResolver->resolve($component->getContext());
+ $this->getResponse()->setHeader('Content-Type', $contentType, true);
}
/** |
Hey @hostep sorry for the late response, I am not sure when this will make it's way into 2.3-develop. |
Ok, let's see what happens. The original issue should be fixed in the security release from 2.1.12 and 2.2.3, so it's not really necessary to backport the PR. The only difference is that the PR added support for both the The only reason I see now to backport the PR, is to have more consistent code in between 2.1, 2.2 & 2.3 |
Hi, @hostep, thank you for collaboration.
|
Ok makes sense to close, since original issue should indeed be fixed by changes in 2.1.12 & 2.2.3. And it was also already "fixed" (more a workaround since the bug was in Magento and not in New Relic) in New Relic's PHP agent some time ago: https://docs.newrelic.com/docs/release-notes/agent-release-notes/php-release-notes/php-agent-760201:
|
…ontent-Type to Ajax responses in the Magento_UI module. #10521
(cherry picked from commit ddfc01e)
Description
This is a backport of #10521 for Magento 2.1
Fixed Issues (if relevant)
Contribution checklist