Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions app/code/Magento/Config/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,14 @@ private function getField(string $sectionId, string $groupId, string $fieldId):
* Get field path
*
* @param Field $field
* @param string $fieldId Need for support of clone_field feature
* @param array &$oldConfig Need for compatibility with _processGroup()
* @param array &$extraOldGroups Need for compatibility with _processGroup()
* @return string
*/
private function getFieldPath(Field $field, array &$oldConfig, array &$extraOldGroups): string
private function getFieldPath(Field $field, string $fieldId, array &$oldConfig, array &$extraOldGroups): string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that changing parameters order and adding a new parameter in the middle of the sequence a good idea. Current implementation will broke all usages of getFieldPath method because array will be passed as second parameter instead of string.

Copy link
Member Author

@jbrada jbrada Sep 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I agree with you. But in this case I think i can change the order of the parameters as I did because it is a private method. If it were anything else (protected or public) changing parameters order is of course, unacceptable. There are only 2 usages of the getFieldPath method in Magento/Config/Model/Config and I replaced them in the commit.

{
$path = $field->getGroupPath() . '/' . $field->getId();
$path = $field->getGroupPath() . '/' . $fieldId;

/**
* Look for custom defined field path
Expand Down Expand Up @@ -303,7 +304,7 @@ private function getChangedPaths(
if (isset($groupData['fields'])) {
foreach ($groupData['fields'] as $fieldId => $fieldData) {
$field = $this->getField($sectionId, $groupId, $fieldId);
$path = $this->getFieldPath($field, $oldConfig, $extraOldGroups);
$path = $this->getFieldPath($field, $fieldId, $oldConfig, $extraOldGroups);
if ($this->isValueChanged($oldConfig, $path, $fieldData)) {
$changedPaths[] = $path;
}
Expand Down Expand Up @@ -398,7 +399,7 @@ protected function _processGroup(
$backendModel->addData($data);
$this->_checkSingleStoreMode($field, $backendModel);

$path = $this->getFieldPath($field, $extraOldGroups, $oldConfig);
$path = $this->getFieldPath($field, $fieldId, $extraOldGroups, $oldConfig);
$backendModel->setPath($path)->setValue($fieldData['value']);

$inherit = !empty($fieldData['inherit']);
Expand Down Expand Up @@ -604,4 +605,4 @@ public function getConfigDataValue($path, &$inherit = null, $configData = null)

return $data;
}
}
}