-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Allow configuration paths based on system.xml #31621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hi @navarr. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @navarr,
Thank you for your contribution! Your change looks good to me.
Could you cover your change with some automated tests?
@magento run all tests |
@magento run Functional Tests CE, Functional Tests EE |
@magento run all tests |
@magento run Functional Tests B2B, Functional Tests EE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check my comments and also please add test coverage for new cases.
@@ -40,6 +40,11 @@ public function __construct(Structure $structure) | |||
*/ | |||
public function validate($path) | |||
{ | |||
$element = $this->structure->getElementByConfigPath($path); | |||
if ($element && method_exists($element, 'getConfigPath') && $element->getConfigPath()!==null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Instead of checking that method exists, could we check here that the element is an instance of some class, or maybe not an instance of an element group?
magento2/app/code/Magento/Config/Block/System/Config/Form.php
Lines 301 to 304 in fbfac3e
if ($element instanceof \Magento\Config\Model\Config\Structure\Element\Group) { $this->_initGroup($element, $section, $fieldset); } else { $path = $element->getConfigPath() ?: $element->getPath($fieldPrefix); -
I believe if the
$element->getConfigPath()
will return empty string that's not also good option. I think we should just checkif(... && $element->getConfigPath()) {
. What do you think about it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has been refactored.
@@ -191,7 +191,7 @@ public function getElementByConfigPath($path) | |||
{ | |||
$allPaths = $this->getFieldPaths(); | |||
|
|||
if (isset($allPaths[$path])) { | |||
if (isset($allPaths[$path]) && is_array($allPaths[$path])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain why it wasn't needed earlier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We didn't call it with empty $allPaths before and with the changes at the 'validate' method we can have an error at $path = array_shift($allPaths[$path]) because '$allPaths[$path]' could be 0 (int) instead of array.
@magento run all tests |
@magento run Functional Tests B2B, Functional Tests CE |
Hi @ihor-sviziev, thank you for the review. |
✔️ QA Passed Manual testing scenario:
Before: ✖️ The "sales/general/keyid" path doesn't exist. Verify and try again. After: ✔️
and setting configuration values work as expected. |
Hi @navarr, thank you for your contribution! |
Description (*)
When merged, this code will update the path validator to consider system.xml paths valid (in addition to config.xml paths)
Fixed Issues (if relevant)
Manual testing scenarios (*)
bin/magento config:set sales/general/keyid 1
We can see Value was saved. as expected.
config_path
tosystem.xml
like thisconfig
bin/magento config:set sales/general/keyid 777
AR:
The "sales/general/keyid" path doesn't exist. Verify and try again.
ER:
Value was saved.
Contribution checklist (*)