Skip to content

Commit bd72ae1

Browse files
author
Bohdan Korablov
committed
MAGETWO-87025: Generate SCD in Production mode
1 parent 2c1870b commit bd72ae1

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed

lib/internal/Magento/Framework/App/StaticResource.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Magento\Framework\App\Filesystem\DirectoryList;
99
use Magento\Framework\ObjectManager\ConfigLoaderInterface;
1010
use Magento\Framework\Filesystem;
11+
use Magento\Framework\Config\ConfigOptionsListConstants;
1112
use Psr\Log\LoggerInterface;
1213

1314
/**
@@ -117,7 +118,9 @@ public function launch()
117118
\Magento\Framework\Profiler::reset();
118119
$appMode = $this->state->getMode();
119120
if ($appMode == \Magento\Framework\App\State::MODE_PRODUCTION
120-
&& !$this->deploymentConfig->getConfigData('static_content_on_demand_in_production')
121+
&& !$this->deploymentConfig->getConfigData(
122+
ConfigOptionsListConstants::CONFIG_PATH_SCD_ON_DEMAND_IN_PRODUCTION
123+
)
121124
) {
122125
$this->response->setHttpResponseCode(404);
123126
} else {

lib/internal/Magento/Framework/App/Test/Unit/StaticResourceTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Magento\Framework\ObjectManagerInterface;
1818
use Magento\Framework\App\ObjectManager\ConfigLoader;
1919
use Magento\Framework\App\StaticResource;
20+
use Magento\Framework\Config\ConfigOptionsListConstants;
2021
use Psr\Log\LoggerInterface;
2122
use PHPUnit_Framework_MockObject_MockObject as MockObject;
2223

@@ -152,7 +153,7 @@ public function testLaunch(
152153
) {
153154
$this->deploymentConfigMock->expects($this->exactly($getConfigDataExpects))
154155
->method('getConfigData')
155-
->with('static_content_on_demand_in_production')
156+
->with(ConfigOptionsListConstants::CONFIG_PATH_SCD_ON_DEMAND_IN_PRODUCTION)
156157
->willReturn($staticContentOmDemandInProduction);
157158
$this->stateMock->expects($this->once())
158159
->method('getMode')

lib/internal/Magento/Framework/App/Test/Unit/View/Deployment/VersionTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\App\State;
1111
use Magento\Framework\App\View\Deployment\Version\StorageInterface;
1212
use Psr\Log\LoggerInterface;
13+
use Magento\Framework\Config\ConfigOptionsListConstants;
1314
use PHPUnit_Framework_MockObject_MockObject as MockObject;
1415

1516
/**
@@ -109,7 +110,7 @@ public function testGetValueWithProductionModeAndException()
109110
->willReturn(State::MODE_PRODUCTION);
110111
$this->deploymentConfigMock->expects($this->once())
111112
->method('getConfigData')
112-
->with('static_content_on_demand_in_production')
113+
->with(ConfigOptionsListConstants::CONFIG_PATH_SCD_ON_DEMAND_IN_PRODUCTION)
113114
->willReturn(0);
114115
$this->loggerMock->expects($this->once())
115116
->method('critical')
@@ -142,7 +143,7 @@ public function testGetValueWithProductionModeAndEnabledSCDonDemand()
142143
->willReturn(State::MODE_PRODUCTION);
143144
$this->deploymentConfigMock->expects($this->once())
144145
->method('getConfigData')
145-
->with('static_content_on_demand_in_production')
146+
->with(ConfigOptionsListConstants::CONFIG_PATH_SCD_ON_DEMAND_IN_PRODUCTION)
146147
->willReturn(1);
147148
$this->versionStorageMock->expects($this->once())
148149
->method('save');

lib/internal/Magento/Framework/App/View/Deployment/Version.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
use Magento\Framework\App\DeploymentConfig;
1010
use Magento\Framework\App\ObjectManager;
11+
use Magento\Framework\Config\ConfigOptionsListConstants;
1112
use Psr\Log\LoggerInterface;
1213

1314
/**
@@ -79,7 +80,9 @@ protected function readValue($appMode)
7980
$result = $this->versionStorage->load();
8081
if (!$result) {
8182
if ($appMode == \Magento\Framework\App\State::MODE_PRODUCTION
82-
&& !$this->deploymentConfig->getConfigData('static_content_on_demand_in_production')
83+
&& !$this->deploymentConfig->getConfigData(
84+
ConfigOptionsListConstants::CONFIG_PATH_SCD_ON_DEMAND_IN_PRODUCTION
85+
)
8386
) {
8487
$this->getLogger()->critical('Can not load static content version.');
8588
throw new \UnexpectedValueException(

lib/internal/Magento/Framework/Config/ConfigOptionsListConstants.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class ConfigOptionsListConstants
3636
const CONFIG_PATH_DB_LOGGER_LOG_EVERYTHING = 'db_logger/log_everything';
3737
const CONFIG_PATH_DB_LOGGER_QUERY_TIME_THRESHOLD = 'db_logger/query_time_threshold';
3838
const CONFIG_PATH_DB_LOGGER_INCLUDE_STACKTRACE = 'db_logger/include_stacktrace';
39+
const CONFIG_PATH_SCD_ON_DEMAND_IN_PRODUCTION = 'static_content_on_demand_in_production';
3940
/**#@-*/
4041

4142
/**#@+

0 commit comments

Comments
 (0)