avstudnitz / AvS_ScopeHint2

Magento 2 module for displaying additional information in configuration
157 stars 33 forks source link

Fix array to string conversion exception #30

Closed therouv closed 2 years ago

therouv commented 2 years ago

Changes in https://github.com/avstudnitz/AvS_ScopeHint2/pull/28 introduced a change where the current value and scope value are cast to string. This leads however to the following exception, when using an array-serialized/serialized config field in store configuration:

Exception #0 (Exception): Warning: Array to string conversion in /var/www/html/vendor/avstudnitz/scopehint2/Plugin/ConfigFieldPlugin.php on line 138

Since the array values can be structured in multiple ways, I propose to just skip the array values and not generate a scope hint label for such cases. These kind of arrays often contain multiple entries anyways, so displaying changes in a popover is tricky anyways.

Noticed the bug while trying to configure the DHL extension which uses a custom ArraySerialized class. But Magento has those kind of classes in the core as well.

avstudnitz commented 2 years ago

Thank you @therouv! I noticed the same thing today, and fixed similarily, but your solution is slightly better.