Skip to content

Commit

Permalink
MC-23940: Removing websites or stores together with their configurati…
Browse files Browse the repository at this point in the history
…on from config.php fails
  • Loading branch information
rostyslav-hymon committed Jan 30, 2020
1 parent d71050a commit 581ac89
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app/code/Magento/Config/Model/Config/Importer/SaveProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,21 @@ public function process(array $data)
* @param string $scope The configuration scope (default, website, or store)
* @param string $scopeCode The scope code
* @return void
* @throws \Magento\Framework\Exception\RuntimeException
*/
private function invokeSave(array $scopeData, $scope, $scopeCode = null)
{
$scopeData = array_keys($this->arrayUtils->flatten($scopeData));

foreach ($scopeData as $path) {
$value = $this->scopeConfig->getValue($path, $scope, $scopeCode);
$backendModel = $this->valueFactory->create($path, $value, $scope, $scopeCode);
if ($value !== null) {
$backendModel = $this->valueFactory->create($path, $value, $scope, $scopeCode);

if ($backendModel instanceof Value) {
$backendModel->beforeSave();
$backendModel->afterSave();
if ($backendModel instanceof Value) {
$backendModel->beforeSave();
$backendModel->afterSave();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,37 @@ public function testProcess()

$this->assertSame(null, $this->model->process($data));
}

public function testProcessWithNullValues()
{
$data = [
'default' => [
'advanced' => ['modules_disable_output' => ['Test_Module' => '1']]
],
'websites' => ['test_website' => ['general' => ['locale' => ['timezone' => 'America/Rio_Branco']]]],
];
$this->arrayUtilsMock->expects($this->exactly(2))
->method('flatten')
->willReturnMap([
[
[
'advanced' => ['modules_disable_output' => ['Test_Module' => '1']]
],
'',
'/',
['advanced/modules_disable_output/Test_Module' => '1']
],
[
['general' => ['locale' => ['timezone' => 'America/Rio_Branco']]],
'',
'/',
['general/locale/timezone' => 'America/Rio_Branco']
]
]);
$this->scopeConfigMock->expects($this->exactly(2))
->method('getValue')
->willReturn(null);

$this->assertSame(null, $this->model->process($data));
}
}

0 comments on commit 581ac89

Please sign in to comment.