Skip to content

Commit a4a5f34

Browse files
author
Joan He
authored
Merge pull request #4358 from magento-arcticfoxes/2.3.3-develop-pr
[arcticfoxes] bug fixes
2 parents 6fa79f0 + 6f4bb26 commit a4a5f34

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

app/code/Magento/Theme/Model/Design/BackendModelFactory.php

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
7+
declare(strict_types=1);
8+
69
namespace Magento\Theme\Model\Design;
710

811
use Magento\Framework\App\Config\Value;
@@ -11,6 +14,9 @@
1114
use Magento\Theme\Model\Design\Config\MetadataProvider;
1215
use Magento\Theme\Model\ResourceModel\Design\Config\CollectionFactory;
1316

17+
/**
18+
* Class BackendModelFactory
19+
*/
1420
class BackendModelFactory extends ValueFactory
1521
{
1622
/**
@@ -58,13 +64,15 @@ public function __construct(
5864
*/
5965
public function create(array $data = [])
6066
{
67+
$storedData = $this->getStoredData($data['scope'], $data['scopeId'], $data['config']['path']);
68+
6169
$backendModelData = array_replace_recursive(
62-
$this->getStoredData($data['scope'], $data['scopeId'], $data['config']['path']),
70+
$storedData,
6371
[
6472
'path' => $data['config']['path'],
6573
'scope' => $data['scope'],
6674
'scope_id' => $data['scopeId'],
67-
'field_config' => $data['config'],
75+
'field_config' => $data['config']
6876
]
6977
);
7078

@@ -76,6 +84,13 @@ public function create(array $data = [])
7684
$backendModel = $this->getNewBackendModel($backendType, $backendModelData);
7785
$backendModel->setValue($data['value']);
7886

87+
if ($storedData) {
88+
foreach ($storedData as $key => $value) {
89+
$backendModel->setOrigData($key, $value);
90+
}
91+
$backendModel->setOrigData('field_config', $data['config']);
92+
}
93+
7994
return $backendModel;
8095
}
8196

@@ -166,9 +181,12 @@ protected function getMetadata()
166181
{
167182
if (!$this->metadata) {
168183
$this->metadata = $this->metadataProvider->get();
169-
array_walk($this->metadata, function (&$value) {
170-
$value = $value['path'];
171-
});
184+
array_walk(
185+
$this->metadata,
186+
function (&$value) {
187+
$value = $value['path'];
188+
}
189+
);
172190
}
173191
return $this->metadata;
174192
}

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
use Magento\Framework\App\Config as AppConfig;
99
use Magento\Framework\App\ScopeFallbackResolverInterface;
1010

11+
/**
12+
* Class ValueChecker
13+
*/
1114
class ValueChecker
1215
{
1316
/**
@@ -61,7 +64,7 @@ public function isDifferentFromDefault($value, $scope, $scopeId, array $fieldCon
6164
$fieldConfig
6265
),
6366
$this->valueProcessor->process(
64-
$this->appConfig->getValue($fieldConfig['path'], $scope, $scopeId),
67+
($this->appConfig->getValue($fieldConfig['path'], $scope, $scopeId) ?? ""),
6568
$scope,
6669
$scopeId,
6770
$fieldConfig
@@ -80,12 +83,11 @@ public function isDifferentFromDefault($value, $scope, $scopeId, array $fieldCon
8083
*/
8184
protected function isEqual($value, $defaultValue)
8285
{
83-
switch (gettype($value)) {
84-
case 'array':
85-
return $this->isEqualArrays($value, $defaultValue);
86-
default:
87-
return $value === $defaultValue;
86+
if (is_array($value)) {
87+
return $this->isEqualArrays($value, $defaultValue);
8888
}
89+
90+
return $value === $defaultValue;
8991
}
9092

9193
/**

0 commit comments

Comments
 (0)