Skip to content

Commit 96a2e17

Browse files
MC-30236: Upgrade from 2.3.x CE with SD to 2.3.x EE AreaCode Exception
1 parent 606c3e8 commit 96a2e17

File tree

1 file changed

+31
-11
lines changed

1 file changed

+31
-11
lines changed

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

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
namespace Magento\Setup\Model;
88

99
use Magento\Backend\Setup\ConfigOptionsList as BackendConfigOptionsList;
10+
use Magento\Framework\App\Cache\Type\Block as BlockCache;
11+
use Magento\Framework\App\Cache\Type\Layout as LayoutCache;
1012
use Magento\Framework\App\DeploymentConfig\Reader;
1113
use Magento\Framework\App\DeploymentConfig\Writer;
1214
use Magento\Framework\App\Filesystem\DirectoryList;
@@ -35,6 +37,7 @@
3537
use Magento\Framework\Setup\SchemaSetupInterface;
3638
use Magento\Framework\Setup\UpgradeDataInterface;
3739
use Magento\Framework\Setup\UpgradeSchemaInterface;
40+
use Magento\PageCache\Model\Cache\Type as PageCache;
3841
use Magento\Setup\Console\Command\InstallCommand;
3942
use Magento\Setup\Controller\ResponseTypeInterface;
4043
use Magento\Setup\Model\ConfigModel as SetupConfigModel;
@@ -336,7 +339,7 @@ public function install($request)
336339
}
337340
$script[] = ['Installing database schema:', 'installSchema', [$request]];
338341
$script[] = ['Installing user configuration...', 'installUserConfig', [$request]];
339-
$script[] = ['Enabling caches:', 'enableCaches', []];
342+
$script[] = ['Enabling caches:', 'updateCaches', [true]];
340343
$script[] = ['Installing data...', 'installDataFixtures', [$request]];
341344
if (!empty($request[InstallCommand::INPUT_KEY_SALES_ORDER_INCREMENT_PREFIX])) {
342345
$script[] = [
@@ -866,6 +869,12 @@ private function convertationOfOldScriptsIsAllowed(array $request)
866869
*/
867870
public function installDataFixtures(array $request = [])
868871
{
872+
$frontendCaches = [
873+
PageCache::TYPE_IDENTIFIER,
874+
BlockCache::TYPE_IDENTIFIER,
875+
LayoutCache::TYPE_IDENTIFIER,
876+
];
877+
869878
/** @var \Magento\Framework\Registry $registry */
870879
$registry = $this->objectManagerProvider->get()->get(\Magento\Framework\Registry::class);
871880
//For backward compatibility in install and upgrade scripts with enabled parallelization.
@@ -876,7 +885,9 @@ public function installDataFixtures(array $request = [])
876885
$setup = $this->dataSetupFactory->create();
877886
$this->checkFilePermissionsForDbUpgrade();
878887
$this->log->log('Data install/update:');
888+
$this->updateCaches(false, $frontendCaches, false);
879889
$this->handleDBSchemaData($setup, 'data', $request);
890+
$this->updateCaches(true, $frontendCaches, false);
880891

881892
$registry->unregister('setup-mode-enabled');
882893
}
@@ -1248,23 +1259,32 @@ public function uninstall()
12481259
}
12491260

12501261
/**
1251-
* Enables caches after installing application
1262+
* Enable or disable caches for specific types
12521263
*
1253-
* @return void
1264+
* If no types are specified then it will enable or disable all available types
1265+
* Note this is called by install() via callback.
12541266
*
1255-
* @SuppressWarnings(PHPMD.UnusedPrivateMethod) Called by install() via callback.
1267+
* @param bool $isEnabled
1268+
* @param array $types
1269+
* @param bool $logStatus
1270+
* @return void
12561271
*/
1257-
private function enableCaches()
1272+
private function updateCaches($isEnabled, $types = [], $logStatus = true)
12581273
{
12591274
/** @var \Magento\Framework\App\Cache\Manager $cacheManager */
12601275
$cacheManager = $this->objectManagerProvider->get()->create(\Magento\Framework\App\Cache\Manager::class);
1261-
$types = $cacheManager->getAvailableTypes();
1262-
$enabledTypes = $cacheManager->setEnabled($types, true);
1263-
$cacheManager->clean($enabledTypes);
1276+
$types = empty($types) ? $cacheManager->getAvailableTypes() : $types;
1277+
1278+
$enabledTypes = $cacheManager->setEnabled($types, $isEnabled);
1279+
if($isEnabled){
1280+
$cacheManager->clean($enabledTypes);
1281+
}
12641282

1265-
$this->log->log('Current status:');
1266-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
1267-
$this->log->log(print_r($cacheManager->getStatus(), true));
1283+
if ($logStatus) {
1284+
$this->log->log('Current status:');
1285+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
1286+
$this->log->log(print_r($cacheManager->getStatus(), true));
1287+
}
12681288
}
12691289

12701290
/**

0 commit comments

Comments
 (0)