Skip to content

Commit db679be

Browse files
author
Alexander Akimov
authored
Merge pull request #2251 from magento-tsg/2.2.4-develop-pr22
[TSG] Backporting for 2.2 (pr22) (2.2.4)
2 parents c42130d + 36f707b commit db679be

File tree

11 files changed

+36
-160
lines changed

11 files changed

+36
-160
lines changed

app/code/Magento/Backend/etc/adminhtml/di.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,6 @@
145145
<item name="dev" xsi:type="const">Magento\Config\Model\Config\Structure\ElementVisibilityInterface::HIDDEN</item>
146146
<item name="general/locale/code" xsi:type="const">Magento\Config\Model\Config\Structure\ElementVisibilityInterface::DISABLED</item>
147147
</argument>
148-
<argument name="exemptions" xsi:type="array">
149-
<item name="dev/debug/debug_logging" xsi:type="string"/>
150-
</argument>
151148
</arguments>
152149
</type>
153150
<type name="Magento\Framework\View\Layout\Generator\Block">

app/code/Magento/Config/Model/Config/Structure/ConcealInProductionConfigList.php

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -42,36 +42,14 @@ class ConcealInProductionConfigList implements ElementVisibilityInterface
4242
*/
4343
private $state;
4444

45-
/**
46-
*
47-
* The list of form element paths which ignore visibility status.
48-
*
49-
* E.g.
50-
*
51-
* ```php
52-
* [
53-
* 'general/country/default' => '',
54-
* ];
55-
* ```
56-
*
57-
* It means that:
58-
* - field 'default' in group Country Options (in section General) will be showed, even if all group(section)
59-
* will be hidden.
60-
*
61-
* @var array
62-
*/
63-
private $exemptions = [];
64-
6545
/**
6646
* @param State $state The object that has information about the state of the system
6747
* @param array $configs The list of form element paths with concrete visibility status.
68-
* @param array $exemptions The list of form element paths which ignore visibility status.
6948
*/
70-
public function __construct(State $state, array $configs = [], array $exemptions = [])
49+
public function __construct(State $state, array $configs = [])
7150
{
7251
$this->state = $state;
7352
$this->configs = $configs;
74-
$this->exemptions = $exemptions;
7553
}
7654

7755
/**
@@ -80,21 +58,10 @@ public function __construct(State $state, array $configs = [], array $exemptions
8058
*/
8159
public function isHidden($path)
8260
{
83-
$result = false;
8461
$path = $this->normalizePath($path);
85-
if ($this->state->getMode() === State::MODE_PRODUCTION
86-
&& preg_match('/(?<group>(?<section>.*?)\/.*?)\/.*?/', $path, $match)) {
87-
$group = $match['group'];
88-
$section = $match['section'];
89-
$exemptions = array_keys($this->exemptions);
90-
foreach ($this->configs as $configPath => $value) {
91-
if ($value === static::HIDDEN && strpos($path, $configPath) !==false) {
92-
$result = empty(array_intersect([$section, $group, $path], $exemptions));
93-
}
94-
}
95-
}
96-
97-
return $result;
62+
return $this->state->getMode() === State::MODE_PRODUCTION
63+
&& !empty($this->configs[$path])
64+
&& $this->configs[$path] === static::HIDDEN;
9865
}
9966

10067
/**

app/code/Magento/Config/Test/Unit/Model/Config/Structure/ConcealInProductionConfigListTest.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,9 @@ protected function setUp()
3333
'third/path' => 'no',
3434
'third/path/field' => ConcealInProductionConfigList::DISABLED,
3535
'first/path/field' => 'no',
36-
'fourth' => ConcealInProductionConfigList::HIDDEN,
37-
];
38-
$exemptions = [
39-
'fourth/path/value' => '',
4036
];
4137

42-
$this->model = new ConcealInProductionConfigList($this->stateMock, $configs, $exemptions);
38+
$this->model = new ConcealInProductionConfigList($this->stateMock, $configs);
4339
}
4440

4541
/**
@@ -100,10 +96,8 @@ public function hiddenDataProvider()
10096
['first/path', State::MODE_PRODUCTION, false],
10197
['first/path', State::MODE_DEFAULT, false],
10298
['some/path', State::MODE_PRODUCTION, false],
103-
['second/path/field', State::MODE_PRODUCTION, true],
99+
['second/path', State::MODE_PRODUCTION, true],
104100
['second/path', State::MODE_DEVELOPER, false],
105-
['fourth/path/value', State::MODE_PRODUCTION, false],
106-
['fourth/path/test', State::MODE_PRODUCTION, true],
107101
];
108102
}
109103
}

app/code/Magento/Deploy/App/Mode/ConfigProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ConfigProvider
1616
* [
1717
* 'developer' => [
1818
* 'production' => [
19-
* {{setting_path}} => ['value' => {{setting_value}}, 'lock' => {{lock_value}}]
19+
* {{setting_path}} => {{setting_value}}
2020
* ]
2121
* ]
2222
* ]
@@ -41,7 +41,7 @@ public function __construct(array $config = [])
4141
* need to turn off 'dev/debug/debug_logging' setting in this case method
4242
* will return array
4343
* [
44-
* {{setting_path}} => ['value' => {{setting_value}}, 'lock' => {{lock_value}}]
44+
* {{setting_path}} => {{setting_value}}
4545
* ]
4646
*
4747
* @param string $currentMode

app/code/Magento/Deploy/Model/Mode.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,17 +234,17 @@ protected function setStoreMode($mode)
234234
private function saveAppConfigs($mode)
235235
{
236236
$configs = $this->configProvider->getConfigs($this->getMode(), $mode);
237-
foreach ($configs as $path => $item) {
238-
$this->emulatedAreaProcessor->process(function () use ($path, $item) {
237+
foreach ($configs as $path => $value) {
238+
$this->emulatedAreaProcessor->process(function () use ($path, $value) {
239239
$this->processorFacadeFactory->create()->processWithLockTarget(
240240
$path,
241-
$item['value'],
241+
$value,
242242
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
243243
null,
244-
$item['lock']
244+
true
245245
);
246246
});
247-
$this->output->writeln('Config "' . $path . ' = ' . $item['value'] . '" has been saved.');
247+
$this->output->writeln('Config "' . $path . ' = ' . $value . '" has been saved.');
248248
}
249249
}
250250
}

app/code/Magento/Deploy/Test/Unit/Model/ModeTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public function testEnableProductionModeMinimal()
228228
->method('getConfigs')
229229
->with('developer', 'production')
230230
->willReturn([
231-
'dev/debug/debug_logging' => ['value' => 0, 'lock' => false]
231+
'dev/debug/debug_logging' => 0
232232
]);
233233
$this->emulatedAreaProcessor->expects($this->once())
234234
->method('process')
@@ -247,7 +247,7 @@ public function testEnableProductionModeMinimal()
247247
0,
248248
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
249249
null,
250-
false
250+
true
251251
);
252252
$this->outputMock->expects($this->once())
253253
->method('writeln')

app/code/Magento/Deploy/etc/di.xml

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
<item name="dumpApplicationCommand" xsi:type="object">\Magento\Deploy\Console\Command\App\ApplicationDumpCommand</item>
3232
<item name="sensitiveConfigSetCommand" xsi:type="object">\Magento\Deploy\Console\Command\App\SensitiveConfigSetCommand</item>
3333
<item name="configImportCommand" xsi:type="object">Magento\Deploy\Console\Command\App\ConfigImportCommand</item>
34-
<item name="configStatusCommand" xsi:type="object">Magento\Deploy\Console\Command\App\ConfigStatusCommand</item>
3534
</argument>
3635
</arguments>
3736
</type>
@@ -76,32 +75,7 @@
7675
<argument name="config" xsi:type="array">
7776
<item name="developer" xsi:type="array">
7877
<item name="production" xsi:type="array">
79-
<item name="dev/debug/debug_logging" xsi:type="array">
80-
<item name="value" xsi:type="string">0</item>
81-
<item name="lock" xsi:type="boolean">false</item>
82-
</item>
83-
</item>
84-
</item>
85-
<item name="production" xsi:type="array">
86-
<item name="developer" xsi:type="array">
87-
<item name="dev/debug/debug_logging" xsi:type="array">
88-
<item name="value" xsi:type="string">1</item>
89-
<item name="lock" xsi:type="boolean">false</item>
90-
</item>
91-
</item>
92-
</item>
93-
<item name="default" xsi:type="array">
94-
<item name="production" xsi:type="array">
95-
<item name="dev/debug/debug_logging" xsi:type="array">
96-
<item name="value" xsi:type="string">0</item>
97-
<item name="lock" xsi:type="boolean">false</item>
98-
</item>
99-
</item>
100-
<item name="developer" xsi:type="array">
101-
<item name="dev/debug/debug_logging" xsi:type="array">
102-
<item name="value" xsi:type="string">1</item>
103-
<item name="lock" xsi:type="boolean">false</item>
104-
</item>
78+
<item name="dev/debug/debug_logging" xsi:type="string">0</item>
10579
</item>
10680
</item>
10781
</argument>

app/code/Magento/Developer/etc/adminhtml/system.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<group id="debug" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
2929
<field id="debug_logging" translate="label comment" type="select" sortOrder="30" showInDefault="1" showInWebsite="0" showInStore="0">
3030
<label>Log to File</label>
31+
<comment>Not available in production mode.</comment>
3132
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
3233
</field>
3334
</group>

dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Config/Form.php

Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,17 @@ class Form extends Block
6060
*/
6161
public function getGroup($tabName, $groupName)
6262
{
63-
$this->openTab($tabName);
63+
$this->baseUrl = $this->getBrowserUrl();
64+
if (substr($this->baseUrl, -1) !== '/') {
65+
$this->baseUrl = $this->baseUrl . '/';
66+
}
67+
68+
$tabUrl = $this->getTabUrl($tabName);
69+
70+
if ($this->getBrowserUrl() !== $tabUrl) {
71+
$this->browser->open($tabUrl);
72+
}
73+
$this->waitForElementNotVisible($this->tabReadiness);
6474

6575
$groupElement = $this->_rootElement->find(
6676
sprintf($this->groupBlock, $tabName, $groupName),
@@ -85,24 +95,6 @@ public function getGroup($tabName, $groupName)
8595
return $blockFactory->getMagentoBackendSystemConfigFormGroup($groupElement);
8696
}
8797

88-
/**
89-
* Check whether specified group presented on page.
90-
*
91-
* @param string $tabName
92-
* @param string $groupName
93-
*
94-
* @return bool
95-
*/
96-
public function isGroupVisible(string $tabName, string $groupName)
97-
{
98-
$this->openTab($tabName);
99-
100-
return $this->_rootElement->find(
101-
sprintf($this->groupBlockLink, $tabName, $groupName),
102-
Locator::SELECTOR_CSS
103-
)->isVisible();
104-
}
105-
10698
/**
10799
* Retrieve url associated with the form.
108100
*/
@@ -145,24 +137,4 @@ private function getTabUrl($tabName)
145137

146138
return $tabUrl;
147139
}
148-
149-
/**
150-
* Open specified tab.
151-
*
152-
* @param string $tabName
153-
* @return void
154-
*/
155-
private function openTab(string $tabName)
156-
{
157-
$this->baseUrl = $this->getBrowserUrl();
158-
if (substr($this->baseUrl, -1) !== '/') {
159-
$this->baseUrl = $this->baseUrl . '/';
160-
}
161-
$tabUrl = $this->getTabUrl($tabName);
162-
163-
if ($this->getBrowserUrl() !== $tabUrl) {
164-
$this->browser->open($tabUrl);
165-
}
166-
$this->waitForElementNotVisible($this->tabReadiness);
167-
}
168140
}

dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertDeveloperSectionVisibility.php

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,57 +9,27 @@
99
use Magento\Backend\Test\Page\Adminhtml\SystemConfigEdit;
1010

1111
/**
12-
* Assert that all groups in Developer section is not present in production mode except debug group "Log to File" field.
12+
* Assert that Developer section is not present in production mode.
1313
*/
1414
class AssertDeveloperSectionVisibility extends AbstractConstraint
1515
{
1616
/**
17-
* List of groups not visible in production mode.
18-
*
19-
* @var array
20-
*/
21-
private $groups = [
22-
'front_end_development_workflow',
23-
'restrict',
24-
'template',
25-
'translate_inline',
26-
'js',
27-
'css',
28-
'image',
29-
'static',
30-
'grid',
31-
];
32-
33-
/**
34-
* Assert all groups in Developer section is not present in production mode except debug group "Log to File" field.
17+
* Assert Developer section is not present in production mode.
3518
*
3619
* @param SystemConfigEdit $configEdit
3720
* @return void
3821
*/
3922
public function processAssert(SystemConfigEdit $configEdit)
4023
{
41-
$configEdit->open();
4224
if ($_ENV['mage_mode'] === 'production') {
43-
foreach ($this->groups as $group) {
44-
\PHPUnit_Framework_Assert::assertFalse(
45-
$configEdit->getForm()->isGroupVisible('dev', $group),
46-
sprintf('%s group should be hidden in production mode.', $group)
47-
);
48-
}
49-
\PHPUnit_Framework_Assert::assertTrue(
50-
$configEdit->getForm()->getGroup('dev', 'debug')->isFieldVisible('dev', 'debug_debug', 'logging'),
51-
'"Log to File" should be presented in production mode.'
25+
\PHPUnit_Framework_Assert::assertFalse(
26+
in_array('Developer', $configEdit->getTabs()->getSubTabsNames('Advanced')),
27+
'Developer section should be hidden in production mode.'
5228
);
5329
} else {
54-
foreach ($this->groups as $group) {
55-
\PHPUnit_Framework_Assert::assertTrue(
56-
$configEdit->getForm()->isGroupVisible('dev', $group),
57-
sprintf('%s group should be visible in developer mode.', $group)
58-
);
59-
}
6030
\PHPUnit_Framework_Assert::assertTrue(
61-
$configEdit->getForm()->isGroupVisible('dev', 'debug'),
62-
'Debug group should be visible in developer mode.'
31+
in_array('Developer', $configEdit->getTabs()->getSubTabsNames('Advanced')),
32+
'Developer section should be not hidden in developer or default mode.'
6333
);
6434
}
6535
}

dev/tests/integration/testsuite/Magento/Developer/Model/Logger/Handler/DebugTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public function setUp()
9595

9696
// Preconditions
9797
$this->mode->enableDeveloperMode();
98+
$this->enableDebugging();
9899
if (file_exists($this->getDebuggerLogPath())) {
99100
unlink($this->getDebuggerLogPath());
100101
}

0 commit comments

Comments
 (0)