From c678635045b0d82420068fcfe3d31f6455774379 Mon Sep 17 00:00:00 2001 From: Eric Wiese Date: Sat, 7 Jan 2017 08:47:45 -0600 Subject: [PATCH] Fix #8, undefined index error on pages with non-standard fields renderers --- .../Framework/Data/Form/Element/Fieldset.php | 43 +++++++++++++------ README.md | 9 +++- composer.json | 5 ++- etc/module.xml | 2 +- 4 files changed, 42 insertions(+), 17 deletions(-) diff --git a/Plugin/Framework/Data/Form/Element/Fieldset.php b/Plugin/Framework/Data/Form/Element/Fieldset.php index 6d7efc5..d9414da 100644 --- a/Plugin/Framework/Data/Form/Element/Fieldset.php +++ b/Plugin/Framework/Data/Form/Element/Fieldset.php @@ -29,6 +29,21 @@ public function __construct( $this->request = $request; } + /** + * Check for indexes of $config that must be present + * for current override detection logic. + * + * @param array $config + * @return bool + */ + protected function isConfigValid(array $config) { + return isset($config['field_config']) + && isset($config['field_config']['path']) + && isset($config['field_config']['id']) + && isset($config['scope']) + && isset($config['scope_id']); + } + /** * If field is overwritten at more specific scope(s), * set field hint with this info. @@ -43,19 +58,21 @@ public function __construct( * @return \Magento\Framework\Data\Form\Element\AbstractElement */ public function aroundAddField(OriginalFieldset $subject, callable $proceed, $elementId, $type, $config, $after = false, $isAdvanced = false) { - $path = $config['field_config']['path'] . '/' . $config['field_config']['id']; - $scope = $config['scope']; - $scopeId = $config['scope_id']; - $section = $this->request->getParam('section'); //@todo: don't talk to request directly - - $overriddenLevels = $this->helper->getOverriddenLevels( - $path, - $scope, - $scopeId - ); - - if(!empty($overriddenLevels)) { - $config['comment'] .= $this->helper->formatOverriddenScopes($section, $overriddenLevels); + if($this->isConfigValid($config)) { + $path = $config['field_config']['path'] . '/' . $config['field_config']['id']; + $scope = $config['scope']; + $scopeId = $config['scope_id']; + $section = $this->request->getParam('section'); //@todo: don't talk to request directly + + $overriddenLevels = $this->helper->getOverriddenLevels( + $path, + $scope, + $scopeId + ); + + if(!empty($overriddenLevels)) { + $config['comment'] .= $this->helper->formatOverriddenScopes($section, $overriddenLevels); + } } return $proceed($elementId, $type, $config, $after, $isAdvanced); diff --git a/README.md b/README.md index bd45c29..6553aec 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ Along with the alert message, a detailed list of the exact scope(s) that overrid ## Compatibility and Technical Notes -Version 3.0.0 of this module has been tested against Magento 2.1.x. It's likely compatible with 2.0.x as well, but this is untested. +As of version 3.0.0 of this module has been tested against Magento 2.1.x. It's likely compatible with 2.0.x as well, but this is untested. > NOTE: For known compatibility with 2.0.x, check out version [2.1.0][2.1.0] of the module. @@ -67,6 +67,13 @@ When used on Magento 2.1.3, the module can produce a false positive when viewing This is a known [core bug][MAGETWO-62648]. +### Non-standard Fieldset Renderers + +Store config groups which use non-standard fieldset renderers are currently ignored. Of the native store config fields, the following exhibit this trait. + +* Advanced -> Advanced -> Disable Modules Output +* Sales -> Payment Methods + [2.1.0]: https://github.com/ericthehacker/magento2-configscopehints/releases/tag/v2.1.0 [MAGETWO-62648]: https://github.com/magento/magento2/issues/7943 \ No newline at end of file diff --git a/composer.json b/composer.json index 02e8f9b..bceb82a 100644 --- a/composer.json +++ b/composer.json @@ -2,10 +2,11 @@ "name": "ericthehacker/magento2-configscopehints", "description": "Magento 2 store config override hints module", "require": { - "magento/framework": "*" + "magento/framework": "*", + "magento/module-config": "*" }, "type": "magento2-module", - "version": "2.1", + "version": "3.1.1", "autoload": { "files": [ "registration.php" ], "psr-4": { diff --git a/etc/module.xml b/etc/module.xml index 373d5c0..6d3a062 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,5 +1,5 @@ - +