Skip to content

Commit efacaca

Browse files
MC-36110: Remove google-shopping-ads clean cache fails
1 parent e6deb9c commit efacaca

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

setup/src/Magento/Setup/Model/Installer.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Backend\Setup\ConfigOptionsList as BackendConfigOptionsList;
1010
use Magento\Framework\App\Cache\Manager;
1111
use Magento\Framework\App\Cache\Type\Block as BlockCache;
12+
use Magento\Framework\App\Cache\Type\Config as ConfigCache;
1213
use Magento\Framework\App\Cache\Type\Layout as LayoutCache;
1314
use Magento\Framework\App\DeploymentConfig\Reader;
1415
use Magento\Framework\App\DeploymentConfig\Writer;
@@ -1291,6 +1292,7 @@ public function updateModulesSequence($keepGeneratedFiles = false)
12911292
. " Run 'magento setup:config:set --help' for options."
12921293
);
12931294
}
1295+
$this->flushCaches([ConfigCache::TYPE_IDENTIFIER]);
12941296
$this->cleanCaches();
12951297
if (!$keepGeneratedFiles) {
12961298
$this->cleanupGeneratedFiles();
@@ -1397,6 +1399,25 @@ private function cleanCaches()
13971399
$this->log->log('Cache cleared successfully');
13981400
}
13991401

1402+
/**
1403+
* Flush caches for specific types or all available types
1404+
*
1405+
* @param array $types
1406+
* @return void
1407+
*
1408+
* @throws Exception
1409+
*/
1410+
private function flushCaches($types = [])
1411+
{
1412+
/** @var Manager $cacheManager */
1413+
$cacheManager = $this->objectManagerProvider->get()->get(Manager::class);
1414+
if (empty($types)) {
1415+
$types = $cacheManager->getAvailableTypes();
1416+
}
1417+
$cacheManager->flush($types);
1418+
$this->log->log('Cache types ' . implode(',', $types) . ' flushed successfully');
1419+
}
1420+
14001421
/**
14011422
* Enables or disables maintenance mode for Magento application
14021423
*

setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -588,11 +588,12 @@ public function testUpdateModulesSequence()
588588
);
589589
$installer = $this->prepareForUpdateModulesTests();
590590

591-
$this->logger->expects($this->at(0))->method('log')->with('Cache cleared successfully');
592-
$this->logger->expects($this->at(1))->method('log')->with('File system cleanup:');
593-
$this->logger->expects($this->at(2))->method('log')
591+
$this->logger->expects($this->at(0))->method('log')->with('Cache types config flushed successfully');
592+
$this->logger->expects($this->at(1))->method('log')->with('Cache cleared successfully');
593+
$this->logger->expects($this->at(2))->method('log')->with('File system cleanup:');
594+
$this->logger->expects($this->at(3))->method('log')
594595
->with('The directory \'/generation\' doesn\'t exist - skipping cleanup');
595-
$this->logger->expects($this->at(3))->method('log')->with('Updating modules:');
596+
$this->logger->expects($this->at(4))->method('log')->with('Updating modules:');
596597
$installer->updateModulesSequence(false);
597598
}
598599

@@ -602,8 +603,9 @@ public function testUpdateModulesSequenceKeepGenerated()
602603

603604
$installer = $this->prepareForUpdateModulesTests();
604605

605-
$this->logger->expects($this->at(0))->method('log')->with('Cache cleared successfully');
606-
$this->logger->expects($this->at(1))->method('log')->with('Updating modules:');
606+
$this->logger->expects($this->at(0))->method('log')->with('Cache types config flushed successfully');
607+
$this->logger->expects($this->at(1))->method('log')->with('Cache cleared successfully');
608+
$this->logger->expects($this->at(2))->method('log')->with('Updating modules:');
607609
$installer->updateModulesSequence(true);
608610
}
609611

0 commit comments

Comments
 (0)