ecommpro/custom-currency

We're sorry, an error has occurred while generating this content - E_NOTICE in core triggered by EnsureTabExistsPlugin

Opened this issue · 1 comments

Hi,

Commit 5176526 added a plugin to \Magento\Config\Model\Config\Structure\Data, which adds to the config array regardless of context. I have another module (BSSCommerce Customer Approval) which sends email out from a frontend controller, in a backend context (to notify the admin). Somehow that results in use of \Magento\Email\Model\BackendTemplate being used which triggers this plugin but with an empty config array. Our plugin adds the 'tabs' entry which then triggers an undefined variable on line 235 of \Magento\Config\Model\Config\Structure because the 'sections' entry isn't there.

That undefined variable notice gets turned into an exception by Magento's error handler, which in the case of an email template will turn the template output into "We're sorry, an error has occurred while generating this content".

We should either move this plugin into etc/adminhtml/di.xml or add an extra check so it only adds the tab if the 'tabs' entry is present already. Do you have a preference?

Is it also possible this isn't needed? I guess it was a workaround for some issue!

(I can send a PR, will test first to see if putting it in adminhtml/di.xml works)