Skip to content

Commit ab3f767

Browse files
committed
Rework for PR #16222 .
When running 'app:config:dump', admin fields get disabled, but clicking save will process them anyway This behaivour causes a validation check on empty fields since the admin form fields are disabled. This commit checks when the field is read only and skips its save.
1 parent e80727a commit ab3f767

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
*/
66
namespace Magento\Config\Model;
77

8+
use Magento\Config\Model\Config\Reader\Source\Deployed\SettingChecker;
89
use Magento\Config\Model\Config\Structure\Element\Group;
910
use Magento\Config\Model\Config\Structure\Element\Field;
11+
use Magento\Framework\App\ObjectManager;
1012

1113
/**
1214
* Backend config model
@@ -80,6 +82,11 @@ class Config extends \Magento\Framework\DataObject
8082
*/
8183
protected $_storeManager;
8284

85+
/**
86+
* @var Config\Reader\Source\Deployed\SettingChecker
87+
*/
88+
private $settingChecker;
89+
8390
/**
8491
* @param \Magento\Framework\App\Config\ReinitableConfigInterface $config
8592
* @param \Magento\Framework\Event\ManagerInterface $eventManager
@@ -88,6 +95,7 @@ class Config extends \Magento\Framework\DataObject
8895
* @param \Magento\Config\Model\Config\Loader $configLoader
8996
* @param \Magento\Framework\App\Config\ValueFactory $configValueFactory
9097
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
98+
* @param Config\Reader\Source\Deployed\SettingChecker|null $settingChecker
9199
* @param array $data
92100
*/
93101
public function __construct(
@@ -98,6 +106,7 @@ public function __construct(
98106
\Magento\Config\Model\Config\Loader $configLoader,
99107
\Magento\Framework\App\Config\ValueFactory $configValueFactory,
100108
\Magento\Store\Model\StoreManagerInterface $storeManager,
109+
SettingChecker $settingChecker = null,
101110
array $data = []
102111
) {
103112
parent::__construct($data);
@@ -108,6 +117,7 @@ public function __construct(
108117
$this->_configLoader = $configLoader;
109118
$this->_configValueFactory = $configValueFactory;
110119
$this->_storeManager = $storeManager;
120+
$this->settingChecker = $settingChecker ?: ObjectManager::getInstance()->get(SettingChecker::class);
111121
}
112122

113123
/**
@@ -351,6 +361,16 @@ protected function _processGroup(
351361
// use extra memory
352362
$fieldsetData = [];
353363
foreach ($groupData['fields'] as $fieldId => $fieldData) {
364+
$isReadOnly = $this->settingChecker->isReadOnly(
365+
$groupPath . '/' . $fieldId,
366+
$this->getScope(),
367+
$this->getScopeCode()
368+
);
369+
370+
if ($isReadOnly) {
371+
continue;
372+
}
373+
354374
$field = $this->getField($sectionPath, $groupId, $fieldId);
355375
/** @var \Magento\Framework\App\Config\ValueInterface $backendModel */
356376
$backendModel = $field->hasBackendModel()

0 commit comments

Comments
 (0)