Skip to content

Commit ee507f6

Browse files
committed
Merge remote-tracking branch '38215/stop-flushing-fpc-when-not-asked-for' into comm_prs_247beta3_dec
2 parents a2519ca + 37f685c commit ee507f6

File tree

5 files changed

+44
-14
lines changed

5 files changed

+44
-14
lines changed

app/code/Magento/Backend/Console/Command/CacheCleanCommand.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
class CacheCleanCommand extends AbstractCacheTypeManageCommand
1616
{
1717
/**
18-
* {@inheritdoc}
18+
* @inheritdoc
1919
*/
2020
protected function configure()
2121
{
@@ -32,12 +32,15 @@ protected function configure()
3232
*/
3333
protected function performAction(array $cacheTypes)
3434
{
35-
$this->eventManager->dispatch('adminhtml_cache_flush_system');
35+
if ($cacheTypes === [] || in_array('full_page', $cacheTypes)) {
36+
$this->eventManager->dispatch('adminhtml_cache_flush_system');
37+
}
38+
3639
$this->cacheManager->clean($cacheTypes);
3740
}
3841

3942
/**
40-
* {@inheritdoc}
43+
* @inheritdoc
4144
*/
4245
protected function getDisplayMessage()
4346
{

app/code/Magento/Backend/Console/Command/CacheFlushCommand.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
class CacheFlushCommand extends AbstractCacheTypeManageCommand
1616
{
1717
/**
18-
* {@inheritdoc}
18+
* @inheritdoc
1919
*/
2020
protected function configure()
2121
{
@@ -32,12 +32,15 @@ protected function configure()
3232
*/
3333
protected function performAction(array $cacheTypes)
3434
{
35-
$this->eventManager->dispatch('adminhtml_cache_flush_all');
35+
if ($cacheTypes === [] || in_array('full_page', $cacheTypes)) {
36+
$this->eventManager->dispatch('adminhtml_cache_flush_all');
37+
}
38+
3639
$this->cacheManager->flush($cacheTypes);
3740
}
3841

3942
/**
40-
* {@inheritdoc}
43+
* @inheritdoc
4144
*/
4245
protected function getDisplayMessage()
4346
{

app/code/Magento/Backend/Test/Unit/Console/Command/AbstractCacheManageCommandTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,22 @@ public function executeDataProvider()
3535
return [
3636
'implicit all' => [
3737
[],
38-
['A', 'B', 'C'],
39-
$this->getExpectedExecutionOutput(['A', 'B', 'C']),
38+
['A', 'B', 'C', 'full_page'],
39+
true,
40+
$this->getExpectedExecutionOutput(['A', 'B', 'C', 'full_page']),
4041
],
4142
'specified types' => [
4243
['types' => ['A', 'B']],
4344
['A', 'B'],
45+
false,
4446
$this->getExpectedExecutionOutput(['A', 'B']),
4547
],
48+
'fpc_only' => [
49+
['types' => ['full_page']],
50+
['full_page'],
51+
true,
52+
$this->getExpectedExecutionOutput(['full_page']),
53+
],
4654
];
4755
}
4856

app/code/Magento/Backend/Test/Unit/Console/Command/CacheCleanCommandTest.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,22 @@ protected function setUp(): void
2222
/**
2323
* @param array $param
2424
* @param array $types
25+
* @param bool $shouldDispatch
2526
* @param string $output
2627
* @dataProvider executeDataProvider
2728
*/
28-
public function testExecute($param, $types, $output)
29+
public function testExecute($param, $types, $shouldDispatch, $output)
2930
{
30-
$this->cacheManagerMock->expects($this->once())->method('getAvailableTypes')->willReturn(['A', 'B', 'C']);
31+
$this->cacheManagerMock->expects($this->once())->method('getAvailableTypes')->willReturn([
32+
'A', 'B', 'C', 'full_page'
33+
]);
3134
$this->cacheManagerMock->expects($this->once())->method('clean')->with($types);
32-
$this->eventManagerMock->expects($this->once())->method('dispatch')->with($this->cacheEventName);
35+
36+
if ($shouldDispatch) {
37+
$this->eventManagerMock->expects($this->once())->method('dispatch')->with($this->cacheEventName);
38+
} else {
39+
$this->eventManagerMock->expects($this->never())->method('dispatch');
40+
}
3341

3442
$commandTester = new CommandTester($this->command);
3543
$commandTester->execute($param);

app/code/Magento/Backend/Test/Unit/Console/Command/CacheFlushCommandTest.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,22 @@ protected function setUp(): void
2222
/**
2323
* @param array $param
2424
* @param array $types
25+
* @param bool $shouldDispatch
2526
* @param string $output
2627
* @dataProvider executeDataProvider
2728
*/
28-
public function testExecute($param, $types, $output)
29+
public function testExecute($param, $types, $shouldDispatch, $output)
2930
{
30-
$this->cacheManagerMock->expects($this->once())->method('getAvailableTypes')->willReturn(['A', 'B', 'C']);
31+
$this->cacheManagerMock->expects($this->once())->method('getAvailableTypes')->willReturn([
32+
'A', 'B', 'C', 'full_page'
33+
]);
3134
$this->cacheManagerMock->expects($this->once())->method('flush')->with($types);
32-
$this->eventManagerMock->expects($this->once())->method('dispatch')->with($this->cacheEventName);
35+
36+
if ($shouldDispatch) {
37+
$this->eventManagerMock->expects($this->once())->method('dispatch')->with($this->cacheEventName);
38+
} else {
39+
$this->eventManagerMock->expects($this->never())->method('dispatch');
40+
}
3341

3442
$commandTester = new CommandTester($this->command);
3543
$commandTester->execute($param);

0 commit comments

Comments
 (0)