Skip to content

Commit 57c355a

Browse files
Merge forwardport of #12328 to 2.3-develop branch
Applied pull request patch https://github.com/magento/magento2/pull/12328.patch (created by @RomaKis) based on commit(s): 1. 147f638 Fixed GitHub Issues in 2.3-develop branch: - #9742: Default welcome message returns after being deleted (reported by @robgt)
2 parents 2d910df + 0c799d2 commit 57c355a

File tree

4 files changed

+77
-2
lines changed

4 files changed

+77
-2
lines changed

app/code/Magento/Theme/Model/Design/Config/Storage.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,13 @@ public function load($scope, $scopeId)
8787
$scopeId,
8888
$fieldData->getFieldConfig()
8989
);
90-
if ($value !== null) {
91-
$fieldData->setValue($value);
90+
91+
if ($value === null) {
92+
$value = '';
9293
}
94+
$fieldData->setValue($value);
9395
}
96+
9497
return $designConfig;
9598
}
9699

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Theme\Model\Design;
8+
9+
/**
10+
* Test for \Magento\Theme\Model\Design\Config\Storage.
11+
*/
12+
class ConfigTest extends \PHPUnit\Framework\TestCase
13+
{
14+
/**
15+
* @var \Magento\Theme\Model\Design\Config\Storage
16+
*/
17+
private $storage;
18+
19+
protected function setUp()
20+
{
21+
$this->storage = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
22+
\Magento\Theme\Model\Design\Config\Storage::class
23+
);
24+
}
25+
26+
/**
27+
* Test design/header/welcome if it is saved in db as empty(null) it should be shown on backend as empty.
28+
*
29+
* @magentoDataFixture Magento/Theme/_files/config_data.php
30+
*/
31+
public function testLoad()
32+
{
33+
$data = $this->storage->load('stores', 1);
34+
foreach ($data->getExtensionAttributes()->getDesignConfigData() as $configData) {
35+
if ($configData->getPath() == 'design/header/welcome') {
36+
$this->assertSame('', $configData->getValue());
37+
}
38+
}
39+
}
40+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
use Magento\Config\Model\Config\Factory;
8+
use Magento\TestFramework\Helper\Bootstrap;
9+
10+
$objectManager = Bootstrap::getObjectManager();
11+
12+
/** @var Factory $configFactory */
13+
$configFactory = $objectManager->create(Factory::class);
14+
/** @var \Magento\Config\Model\Config $config */
15+
$config = $configFactory->create();
16+
$config->setScope('stores');
17+
$config->setStore('default');
18+
$config->setDataByPath('design/header/welcome', null);
19+
$config->save();
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
8+
/** @var \Magento\Framework\App\ResourceConnection $resource */
9+
$resource = $objectManager->get(\Magento\Framework\App\ResourceConnection::class);
10+
$connection = $resource->getConnection();
11+
$tableName = $resource->getTableName('core_config_data');
12+
13+
$connection->query("DELETE FROM $tableName WHERE path = 'design/header/welcome';");

0 commit comments

Comments
 (0)