Skip to content

Commit

Permalink
Merge pull request #525 from magento-performance/ACPT-1277
Browse files Browse the repository at this point in the history
ACPT-1277: GraphQlCache plugin need to use response parameter
  • Loading branch information
andimov authored May 4, 2023
2 parents 446fbd3 + 49e6db9 commit f2dee6f
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions app/code/Magento/GraphQlCache/Controller/Plugin/GraphQl.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ class GraphQl
*/
private $config;

/**
* @var ResponseHttp
*/
private $response;

/**
* @var HttpRequestProcessor
*/
Expand All @@ -55,7 +50,8 @@ class GraphQl
/**
* @param CacheableQuery $cacheableQuery
* @param Config $config
* @param ResponseHttp $response
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @param ResponseHttp $response @deprecated do not use
* @param HttpRequestProcessor $requestProcessor
* @param Registry $registry
* @param CacheIdCalculator $cacheIdCalculator
Expand All @@ -70,7 +66,6 @@ public function __construct(
) {
$this->cacheableQuery = $cacheableQuery;
$this->config = $config;
$this->response = $response;
$this->requestProcessor = $requestProcessor;
$this->registry = $registry;
$this->cacheIdCalculator = $cacheIdCalculator;
Expand Down Expand Up @@ -109,26 +104,22 @@ public function afterRenderResult(ResultInterface $subject, ResultInterface $res
/** @see \Magento\Framework\App\Http::launch */
/** @see \Magento\PageCache\Model\Controller\Result\BuiltinPlugin::afterRenderResult */
$this->registry->register('use_page_cache_plugin', true, true);

$cacheId = $this->cacheIdCalculator->getCacheId();
if ($cacheId) {
$this->response->setHeader(CacheIdCalculator::CACHE_ID_HEADER, $cacheId, true);
$response->setHeader(CacheIdCalculator::CACHE_ID_HEADER, $cacheId, true);
}

if ($this->cacheableQuery->shouldPopulateCacheHeadersWithTags()) {
$this->response->setPublicHeaders($this->config->getTtl());
$this->response->setHeader('X-Magento-Tags', implode(',', $this->cacheableQuery->getCacheTags()), true);
$response->setPublicHeaders($this->config->getTtl());
$response->setHeader('X-Magento-Tags', implode(',', $this->cacheableQuery->getCacheTags()), true);
} else {
$sendNoCacheHeaders = true;
}
} else {
$sendNoCacheHeaders = true;
}

if ($sendNoCacheHeaders) {
$this->response->setNoCacheHeaders();
$response->setNoCacheHeaders();
}

return $result;
}
}

0 comments on commit f2dee6f

Please sign in to comment.