Skip to content

Commit

Permalink
Merge pull request #10 from ericthehacker/hotfix/github-issue-8
Browse files Browse the repository at this point in the history
Fix #8, undefined index error on pages with non-standard fields renderers
  • Loading branch information
ericthehacker authored Jan 7, 2017
2 parents 80bd8da + c678635 commit 56a04e7
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 17 deletions.
43 changes: 30 additions & 13 deletions Plugin/Framework/Data/Form/Element/Fieldset.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="EW_ConfigScopeHints" setup_version="3.1.0">
<module name="EW_ConfigScopeHints" setup_version="3.1.1">
<sequence>
<module name="Magento_Config"/>
</sequence>
Expand Down

0 comments on commit 56a04e7

Please sign in to comment.