Skip to content

Commit 581ac89

Browse files
MC-23940: Removing websites or stores together with their configuration from config.php fails
1 parent d71050a commit 581ac89

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

app/code/Magento/Config/Model/Config/Importer/SaveProcessor.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,21 @@ public function process(array $data)
9191
* @param string $scope The configuration scope (default, website, or store)
9292
* @param string $scopeCode The scope code
9393
* @return void
94+
* @throws \Magento\Framework\Exception\RuntimeException
9495
*/
9596
private function invokeSave(array $scopeData, $scope, $scopeCode = null)
9697
{
9798
$scopeData = array_keys($this->arrayUtils->flatten($scopeData));
9899

99100
foreach ($scopeData as $path) {
100101
$value = $this->scopeConfig->getValue($path, $scope, $scopeCode);
101-
$backendModel = $this->valueFactory->create($path, $value, $scope, $scopeCode);
102+
if ($value !== null) {
103+
$backendModel = $this->valueFactory->create($path, $value, $scope, $scopeCode);
102104

103-
if ($backendModel instanceof Value) {
104-
$backendModel->beforeSave();
105-
$backendModel->afterSave();
105+
if ($backendModel instanceof Value) {
106+
$backendModel->beforeSave();
107+
$backendModel->afterSave();
108+
}
106109
}
107110
}
108111
}

app/code/Magento/Config/Test/Unit/Model/Config/Importer/SaveProcessorTest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,37 @@ public function testProcess()
136136

137137
$this->assertSame(null, $this->model->process($data));
138138
}
139+
140+
public function testProcessWithNullValues()
141+
{
142+
$data = [
143+
'default' => [
144+
'advanced' => ['modules_disable_output' => ['Test_Module' => '1']]
145+
],
146+
'websites' => ['test_website' => ['general' => ['locale' => ['timezone' => 'America/Rio_Branco']]]],
147+
];
148+
$this->arrayUtilsMock->expects($this->exactly(2))
149+
->method('flatten')
150+
->willReturnMap([
151+
[
152+
[
153+
'advanced' => ['modules_disable_output' => ['Test_Module' => '1']]
154+
],
155+
'',
156+
'/',
157+
['advanced/modules_disable_output/Test_Module' => '1']
158+
],
159+
[
160+
['general' => ['locale' => ['timezone' => 'America/Rio_Branco']]],
161+
'',
162+
'/',
163+
['general/locale/timezone' => 'America/Rio_Branco']
164+
]
165+
]);
166+
$this->scopeConfigMock->expects($this->exactly(2))
167+
->method('getValue')
168+
->willReturn(null);
169+
170+
$this->assertSame(null, $this->model->process($data));
171+
}
139172
}

0 commit comments

Comments
 (0)