Skip to content

Commit 1ad6fd2

Browse files
merge magento/2.3-develop into magento-trigger/MC-15776
2 parents 56e4694 + 777b0b0 commit 1ad6fd2

File tree

7 files changed

+326
-20
lines changed

7 files changed

+326
-20
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\PageCache\Block\System\Config\Form\Field\Export;
7+
8+
/**
9+
* Class Export
10+
*/
11+
class Varnish6 extends \Magento\PageCache\Block\System\Config\Form\Field\Export
12+
{
13+
/**
14+
* Return Varnish version to this class
15+
*
16+
* @return int
17+
*/
18+
public function getVarnishVersion()
19+
{
20+
return 6;
21+
}
22+
}

app/code/Magento/PageCache/Controller/Adminhtml/PageCache/ExportVarnishConfig.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
<?php
22
/**
3-
*
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
76
namespace Magento\PageCache\Controller\Adminhtml\PageCache;
87

8+
use Magento\Framework\App\Action\HttpGetActionInterface;
99
use Magento\Framework\App\Filesystem\DirectoryList;
1010

11-
class ExportVarnishConfig extends \Magento\Backend\App\Action
11+
/**
12+
* Class ExportVarnishConfig action which exports vcl config file
13+
*/
14+
class ExportVarnishConfig extends \Magento\Backend\App\Action implements HttpGetActionInterface
1215
{
1316
/**
1417
* Authorization level of a basic admin session
@@ -50,6 +53,9 @@ public function execute()
5053
$fileName = 'varnish.vcl';
5154
$varnishVersion = $this->getRequest()->getParam('varnish');
5255
switch ($varnishVersion) {
56+
case 6:
57+
$content = $this->config->getVclFile(\Magento\PageCache\Model\Config::VARNISH_6_CONFIGURATION_PATH);
58+
break;
5359
case 5:
5460
$content = $this->config->getVclFile(\Magento\PageCache\Model\Config::VARNISH_5_CONFIGURATION_PATH);
5561
break;

app/code/Magento/PageCache/Model/Config.php

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\PageCache\Model;
78

89
use Magento\Framework\App\ObjectManager;
@@ -12,8 +13,7 @@
1213
use Magento\PageCache\Model\Varnish\VclGeneratorFactory;
1314

1415
/**
15-
* Model is responsible for replacing default vcl template
16-
* file configuration with user-defined from configuration
16+
* Model is responsible for replacing default vcl template file configuration with user-defined from configuration
1717
*
1818
* @api
1919
* @since 100.0.2
@@ -49,6 +49,11 @@ class Config
4949
*/
5050
protected $_scopeConfig;
5151

52+
/**
53+
* XML path to Varnish 6 config template path
54+
*/
55+
const VARNISH_6_CONFIGURATION_PATH = 'system/full_page_cache/varnish6/path';
56+
5257
/**
5358
* XML path to Varnish 5 config template path
5459
*/
@@ -145,19 +150,29 @@ public function getVclFile($vclTemplatePath)
145150
self::XML_VARNISH_PAGECACHE_DESIGN_THEME_REGEX,
146151
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
147152
);
148-
149-
$version = $vclTemplatePath === self::VARNISH_5_CONFIGURATION_PATH ? 5 : 4;
153+
switch ($vclTemplatePath) {
154+
case self::VARNISH_6_CONFIGURATION_PATH:
155+
$version = 6;
156+
break;
157+
case self::VARNISH_5_CONFIGURATION_PATH:
158+
$version = 5;
159+
break;
160+
default:
161+
$version = 4;
162+
}
150163
$sslOffloadedHeader = $this->_scopeConfig->getValue(
151164
\Magento\Framework\HTTP\PhpEnvironment\Request::XML_PATH_OFFLOADER_HEADER
152165
);
153-
$vclGenerator = $this->vclGeneratorFactory->create([
154-
'backendHost' => $this->_scopeConfig->getValue(self::XML_VARNISH_PAGECACHE_BACKEND_HOST),
155-
'backendPort' => $this->_scopeConfig->getValue(self::XML_VARNISH_PAGECACHE_BACKEND_PORT),
156-
'accessList' => $accessList ? explode(',', $accessList) : [],
157-
'designExceptions' => $designExceptions ? $this->serializer->unserialize($designExceptions) : [],
158-
'sslOffloadedHeader' => $sslOffloadedHeader,
159-
'gracePeriod' => $this->_scopeConfig->getValue(self::XML_VARNISH_PAGECACHE_GRACE_PERIOD)
160-
]);
166+
$vclGenerator = $this->vclGeneratorFactory->create(
167+
[
168+
'backendHost' => $this->_scopeConfig->getValue(self::XML_VARNISH_PAGECACHE_BACKEND_HOST),
169+
'backendPort' => $this->_scopeConfig->getValue(self::XML_VARNISH_PAGECACHE_BACKEND_PORT),
170+
'accessList' => $accessList ? explode(',', $accessList) : [],
171+
'designExceptions' => $designExceptions ? $this->serializer->unserialize($designExceptions) : [],
172+
'sslOffloadedHeader' => $sslOffloadedHeader,
173+
'gracePeriod' => $this->_scopeConfig->getValue(self::XML_VARNISH_PAGECACHE_GRACE_PERIOD)
174+
]
175+
);
161176
return $vclGenerator->generateVcl($version);
162177
}
163178

@@ -187,12 +202,12 @@ protected function _getReplacements()
187202
}
188203

189204
/**
190-
* Get IPs access list that can purge Varnish configuration for config file generation
191-
* and transform it to appropriate view
205+
* Get IPs access list allowed purge Varnish config for config file generation and transform it to appropriate view
192206
*
193-
* acl purge{
207+
* Example acl_purge{
194208
* "127.0.0.1";
195209
* "127.0.0.2";
210+
* }
196211
*
197212
* @return mixed|null|string
198213
* @deprecated 100.2.0 see \Magento\PageCache\Model\VclGeneratorInterface::generateVcl

app/code/Magento/PageCache/Model/Varnish/VclTemplateLocator.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,16 @@
1313
use Magento\PageCache\Model\VclTemplateLocatorInterface;
1414
use Magento\PageCache\Exception\UnsupportedVarnishVersion;
1515

16+
/**
17+
* Class VclTemplateLocator provides vcl template path
18+
*/
1619
class VclTemplateLocator implements VclTemplateLocatorInterface
1720
{
21+
/**
22+
* XML path to Varnish 5 config template path
23+
*/
24+
const VARNISH_6_CONFIGURATION_PATH = 'system/full_page_cache/varnish6/path';
25+
1826
/**
1927
* XML path to Varnish 5 config template path
2028
*/
@@ -26,21 +34,27 @@ class VclTemplateLocator implements VclTemplateLocatorInterface
2634
const VARNISH_4_CONFIGURATION_PATH = 'system/full_page_cache/varnish4/path';
2735

2836
/**
29-
*
37+
* Varnish 4 supported version
3038
*/
3139
const VARNISH_SUPPORTED_VERSION_4 = '4';
3240

3341
/**
34-
*
42+
* Varnish 5 supported version
3543
*/
3644
const VARNISH_SUPPORTED_VERSION_5 = '5';
3745

46+
/**
47+
* Varnish 6 supported version
48+
*/
49+
const VARNISH_SUPPORTED_VERSION_6 = '6';
50+
3851
/**
3952
* @var array
4053
*/
4154
private $supportedVarnishVersions = [
4255
self::VARNISH_SUPPORTED_VERSION_4 => self::VARNISH_4_CONFIGURATION_PATH,
4356
self::VARNISH_SUPPORTED_VERSION_5 => self::VARNISH_5_CONFIGURATION_PATH,
57+
self::VARNISH_SUPPORTED_VERSION_6 => self::VARNISH_6_CONFIGURATION_PATH,
4458
];
4559

4660
/**
@@ -73,7 +87,7 @@ public function __construct(Reader $reader, ReadFactory $readFactory, ScopeConfi
7387
}
7488

7589
/**
76-
* {@inheritdoc}
90+
* @inheritdoc
7791
*/
7892
public function getTemplate($version)
7993
{

app/code/Magento/PageCache/etc/adminhtml/system.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@
6262
<field id="caching_application">1</field>
6363
</depends>
6464
</field>
65+
<field id="export_button_version6" type="button" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0">
66+
<frontend_model>Magento\PageCache\Block\System\Config\Form\Field\Export\Varnish6</frontend_model>
67+
<depends>
68+
<field id="caching_application">1</field>
69+
</depends>
70+
</field>
6571
<depends>
6672
<field id="caching_application">2</field>
6773
</depends>

app/code/Magento/PageCache/etc/config.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
</design>
1515
<system>
1616
<full_page_cache>
17+
<varnish6>
18+
<path>varnish6.vcl</path>
19+
</varnish6>
1720
<varnish5>
1821
<path>varnish5.vcl</path>
1922
</varnish5>

0 commit comments

Comments
 (0)