Skip to content

Remove Varnish 4/5 support #38052

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/code/Magento/CacheInvalidate/Model/PurgeCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ class PurgeCache
/**
* Batch size of the purge request.
*
* Based on default Varnish 4 http_req_hdr_len size minus a 512 bytes margin for method,
* Based on default Varnish 6 http_req_hdr_len size minus a 512 bytes margin for method,
* header name, line feeds etc.
*
* @see https://varnish-cache.org/docs/4.1/reference/varnishd.html
* @see https://varnish-cache.org/docs/6.0/reference/varnishd.html
*
* @var int
*/
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,32 @@ class GenerateVclCommand extends Command
/**
* Access list option name
*/
const ACCESS_LIST_OPTION = 'access-list';
public const ACCESS_LIST_OPTION = 'access-list';

/**
* Backend host option name
*/
const BACKEND_HOST_OPTION = 'backend-host';
public const BACKEND_HOST_OPTION = 'backend-host';

/**
* Backend port option name
*/
const BACKEND_PORT_OPTION = 'backend-port';
public const BACKEND_PORT_OPTION = 'backend-port';

/**
* Varnish version option name
*/
const EXPORT_VERSION_OPTION = 'export-version';
public const EXPORT_VERSION_OPTION = 'export-version';

/**
* Grace period option name
*/
const GRACE_PERIOD_OPTION = 'grace-period';
public const GRACE_PERIOD_OPTION = 'grace-period';

/**
* Output file option name
*/
const OUTPUT_FILE_OPTION = 'output-file';
public const OUTPUT_FILE_OPTION = 'output-file';

/**
* @var \Magento\Framework\Filesystem\Directory\WriteFactory
Expand Down Expand Up @@ -192,7 +192,7 @@ private function getOptionList()
null,
InputOption::VALUE_REQUIRED,
'The version of Varnish file',
VclTemplateLocator::VARNISH_SUPPORTED_VERSION_4
VclTemplateLocator::VARNISH_SUPPORTED_VERSION_6
),
new InputOption(
self::GRACE_PERIOD_OPTION,
Expand All @@ -211,6 +211,8 @@ private function getOptionList()
}

/**
* Maps input keys to vcl parameters
*
* @param InputInterface $input
* @return array
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ExportVarnishConfig extends \Magento\Backend\App\Action implements HttpGet
/**
* Authorization level of a basic admin session
*/
const ADMIN_RESOURCE = 'Magento_Backend::system';
public const ADMIN_RESOURCE = 'Magento_Backend::system';

/**
* @var \Magento\Backend\App\Response\Http\FileFactory
Expand Down Expand Up @@ -56,11 +56,8 @@ public function execute()
case 6:
$content = $this->config->getVclFile(\Magento\PageCache\Model\Config::VARNISH_6_CONFIGURATION_PATH);
break;
case 5:
$content = $this->config->getVclFile(\Magento\PageCache\Model\Config::VARNISH_5_CONFIGURATION_PATH);
break;
default:
$content = $this->config->getVclFile(\Magento\PageCache\Model\Config::VARNISH_4_CONFIGURATION_PATH);
$content = $this->config->getVclFile(\Magento\PageCache\Model\Config::VARNISH_6_CONFIGURATION_PATH);
break;
}
return $this->fileFactory->create($fileName, $content, DirectoryList::VAR_DIR);
Expand Down
21 changes: 13 additions & 8 deletions app/code/Magento/PageCache/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,15 @@ class Config
public const VARNISH_6_CONFIGURATION_PATH = 'system/full_page_cache/varnish6/path';

/**
* @deprecated Varnish 5 is EOL
* @see VARNISH_6_CONFIGURATION_PATH
* XML path to Varnish 5 config template path
*/
public const VARNISH_5_CONFIGURATION_PATH = 'system/full_page_cache/varnish5/path';

/**
* @deprecated Varnish 4 is EOL
* @see VARNISH_6_CONFIGURATION_PATH
* XML path to Varnish 4 config template path
*/
public const VARNISH_4_CONFIGURATION_PATH = 'system/full_page_cache/varnish4/path';
Expand Down Expand Up @@ -140,7 +144,8 @@ public function getTtl()
*
* @param string $vclTemplatePath
* @return string
* @deprecated 100.2.0 see \Magento\PageCache\Model\VclGeneratorInterface::generateVcl
* @deprecated 100.2.0
* @see \Magento\PageCache\Model\VclGeneratorInterface::generateVcl
*/
public function getVclFile($vclTemplatePath)
{
Expand All @@ -153,11 +158,8 @@ public function getVclFile($vclTemplatePath)
case self::VARNISH_6_CONFIGURATION_PATH:
$version = 6;
break;
case self::VARNISH_5_CONFIGURATION_PATH:
$version = 5;
break;
default:
$version = 4;
$version = 6;
}
$sslOffloadedHeader = $this->_scopeConfig->getValue(
Request::XML_PATH_OFFLOADER_HEADER
Expand All @@ -179,7 +181,8 @@ public function getVclFile($vclTemplatePath)
* Prepare data for VCL config
*
* @return array
* @deprecated 100.2.0 see \Magento\PageCache\Model\VclGeneratorInterface::generateVcl
* @deprecated 100.2.0
* @see \Magento\PageCache\Model\VclGeneratorInterface::generateVcl
*/
protected function _getReplacements()
{
Expand Down Expand Up @@ -209,7 +212,8 @@ protected function _getReplacements()
* }
*
* @return mixed|null|string
* @deprecated 100.2.0 see \Magento\PageCache\Model\VclGeneratorInterface::generateVcl
* @deprecated 100.2.0
* @see \Magento\PageCache\Model\VclGeneratorInterface::generateVcl
*/
protected function _getAccessList()
{
Expand All @@ -235,7 +239,8 @@ protected function _getAccessList()
* we have to convert "/pattern/iU" into "(?Ui)pattern"
*
* @return string
* @deprecated 100.2.0 see \Magento\PageCache\Model\VclGeneratorInterface::generateVcl
* @deprecated 100.2.0
* @see \Magento\PageCache\Model\VclGeneratorInterface::generateVcl
*/
protected function _getDesignExceptions()
{
Expand Down
27 changes: 16 additions & 11 deletions app/code/Magento/PageCache/Model/Varnish/VclTemplateLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,46 @@
class VclTemplateLocator implements VclTemplateLocatorInterface
{
/**
* XML path to Varnish 5 config template path
* XML path to Varnish 6 config template path
*/
const VARNISH_6_CONFIGURATION_PATH = 'system/full_page_cache/varnish6/path';
public const VARNISH_6_CONFIGURATION_PATH = 'system/full_page_cache/varnish6/path';

/**
* @deprecated Varnish 5 is EOL
* @see VARNISH_6_CONFIGURATION_PATH
* XML path to Varnish 5 config template path
*/
const VARNISH_5_CONFIGURATION_PATH = 'system/full_page_cache/varnish5/path';
public const VARNISH_5_CONFIGURATION_PATH = 'system/full_page_cache/varnish5/path';

/**
* @deprecated Varnish 4 is EOL
* @see VARNISH_6_CONFIGURATION_PATH
* XML path to Varnish 4 config template path
*/
const VARNISH_4_CONFIGURATION_PATH = 'system/full_page_cache/varnish4/path';
public const VARNISH_4_CONFIGURATION_PATH = 'system/full_page_cache/varnish4/path';

/**
* Varnish 4 supported version
* @deprecated Varnish 4 is EOL
* @see VARNISH_SUPPORTED_VERSION_6
*/
const VARNISH_SUPPORTED_VERSION_4 = '4';
public const VARNISH_SUPPORTED_VERSION_4 = '4';

/**
* Varnish 5 supported version
* @deprecated Varnish 5 is EOL
* @see VARNISH_SUPPORTED_VERSION_6
*/
const VARNISH_SUPPORTED_VERSION_5 = '5';
public const VARNISH_SUPPORTED_VERSION_5 = '5';

/**
* Varnish 6 supported version
* @see VARNISH_SUPPORTED_VERSION_6
*/
const VARNISH_SUPPORTED_VERSION_6 = '6';
public const VARNISH_SUPPORTED_VERSION_6 = '6';

/**
* @var array
*/
private $supportedVarnishVersions = [
self::VARNISH_SUPPORTED_VERSION_4 => self::VARNISH_4_CONFIGURATION_PATH,
self::VARNISH_SUPPORTED_VERSION_5 => self::VARNISH_5_CONFIGURATION_PATH,
self::VARNISH_SUPPORTED_VERSION_6 => self::VARNISH_6_CONFIGURATION_PATH,
];

Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/PageCache/Test/Unit/Model/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function testGetVcl(): void
->method('unserialize')
->with('serializedConfig')
->willReturn([['regexp' => '(?i)pattern', 'value' => 'value_for_pattern']]);
$test = $this->config->getVclFile(Config::VARNISH_5_CONFIGURATION_PATH);
$test = $this->config->getVclFile(Config::VARNISH_6_CONFIGURATION_PATH);
$this->assertEquals(file_get_contents(__DIR__ . '/_files/result.vcl'), $test);
}

Expand Down
13 changes: 0 additions & 13 deletions app/code/Magento/PageCache/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,6 @@
<field id="caching_application">1</field>
</depends>
</field>
<field id="export_button_version4" translate="label" type="button" sortOrder="35" showInDefault="1">
<label>Export Configuration</label>
<frontend_model>Magento\PageCache\Block\System\Config\Form\Field\Export\Varnish4</frontend_model>
<depends>
<field id="caching_application">1</field>
</depends>
</field>
<field id="export_button_version5" type="button" sortOrder="40" showInDefault="1">
<frontend_model>Magento\PageCache\Block\System\Config\Form\Field\Export\Varnish5</frontend_model>
<depends>
<field id="caching_application">1</field>
</depends>
</field>
<field id="export_button_version6" type="button" sortOrder="40" showInDefault="1">
<frontend_model>Magento\PageCache\Block\System\Config\Form\Field\Export\Varnish6</frontend_model>
<depends>
Expand Down
6 changes: 0 additions & 6 deletions app/code/Magento/PageCache/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@
<varnish6>
<path>varnish6.vcl</path>
</varnish6>
<varnish5>
<path>varnish5.vcl</path>
</varnish5>
<varnish4>
<path>varnish4.vcl</path>
</varnish4>
<ttl>86400</ttl>
<handles_size>100</handles_size>
<caching_application>1</caching_application>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,13 @@ class ExportTest extends \Magento\TestFramework\TestCase\AbstractBackendControll
/**
* Check Varnish export buttons
* @covers \Magento\PageCache\Block\System\Config\Form\Field\Export::_getElementHtml
* @covers \Magento\PageCache\Block\System\Config\Form\Field\Export\Varnish5::getVarnishVersion
* @covers \Magento\PageCache\Block\System\Config\Form\Field\Export\Varnish4::getVarnishVersion
* @magentoAppIsolation enabled
* @magentoDbIsolation enabled
*/
public function testExportButtons()
{
$this->dispatch('backend/admin/system_config/edit/section/system/');
$body = $this->getResponse()->getBody();
$this->assertStringContainsString('system_full_page_cache_varnish_export_button_version4', $body);
$this->assertStringContainsString('system_full_page_cache_varnish_export_button_version5', $body);
$this->assertStringContainsString('[id^=system_full_page_cache_varnish_export_button_version]', $body);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected function setUp(): void
// @codingStandardsIgnoreEnd
public function testGetVclFile()
{
$result = $this->config->getVclFile(Config::VARNISH_5_CONFIGURATION_PATH);
$result = $this->config->getVclFile(Config::VARNISH_6_CONFIGURATION_PATH);
$this->assertEquals(file_get_contents(__DIR__ . '/_files/result.vcl'), $result);
}
}