Skip to content

Commit f2dee6f

Browse files
authored
Merge pull request #525 from magento-performance/ACPT-1277
ACPT-1277: GraphQlCache plugin need to use response parameter
2 parents 446fbd3 + 49e6db9 commit f2dee6f

File tree

1 file changed

+6
-15
lines changed
  • app/code/Magento/GraphQlCache/Controller/Plugin

1 file changed

+6
-15
lines changed

app/code/Magento/GraphQlCache/Controller/Plugin/GraphQl.php

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ class GraphQl
3232
*/
3333
private $config;
3434

35-
/**
36-
* @var ResponseHttp
37-
*/
38-
private $response;
39-
4035
/**
4136
* @var HttpRequestProcessor
4237
*/
@@ -55,7 +50,8 @@ class GraphQl
5550
/**
5651
* @param CacheableQuery $cacheableQuery
5752
* @param Config $config
58-
* @param ResponseHttp $response
53+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
54+
* @param ResponseHttp $response @deprecated do not use
5955
* @param HttpRequestProcessor $requestProcessor
6056
* @param Registry $registry
6157
* @param CacheIdCalculator $cacheIdCalculator
@@ -70,7 +66,6 @@ public function __construct(
7066
) {
7167
$this->cacheableQuery = $cacheableQuery;
7268
$this->config = $config;
73-
$this->response = $response;
7469
$this->requestProcessor = $requestProcessor;
7570
$this->registry = $registry;
7671
$this->cacheIdCalculator = $cacheIdCalculator;
@@ -109,26 +104,22 @@ public function afterRenderResult(ResultInterface $subject, ResultInterface $res
109104
/** @see \Magento\Framework\App\Http::launch */
110105
/** @see \Magento\PageCache\Model\Controller\Result\BuiltinPlugin::afterRenderResult */
111106
$this->registry->register('use_page_cache_plugin', true, true);
112-
113107
$cacheId = $this->cacheIdCalculator->getCacheId();
114108
if ($cacheId) {
115-
$this->response->setHeader(CacheIdCalculator::CACHE_ID_HEADER, $cacheId, true);
109+
$response->setHeader(CacheIdCalculator::CACHE_ID_HEADER, $cacheId, true);
116110
}
117-
118111
if ($this->cacheableQuery->shouldPopulateCacheHeadersWithTags()) {
119-
$this->response->setPublicHeaders($this->config->getTtl());
120-
$this->response->setHeader('X-Magento-Tags', implode(',', $this->cacheableQuery->getCacheTags()), true);
112+
$response->setPublicHeaders($this->config->getTtl());
113+
$response->setHeader('X-Magento-Tags', implode(',', $this->cacheableQuery->getCacheTags()), true);
121114
} else {
122115
$sendNoCacheHeaders = true;
123116
}
124117
} else {
125118
$sendNoCacheHeaders = true;
126119
}
127-
128120
if ($sendNoCacheHeaders) {
129-
$this->response->setNoCacheHeaders();
121+
$response->setNoCacheHeaders();
130122
}
131-
132123
return $result;
133124
}
134125
}

0 commit comments

Comments
 (0)