Magento2: Config Parsing Fails - Brain Tree - invalid argument supplied for foreach()

Created on 16 Nov 2017  Â·  17Comments  Â·  Source: magento/magento2


Preconditions


  1. Mag 2.2.1
  2. On System .*

Steps to reproduce

  1. Configure Braintree payment system
  2. magento app:config:dump
  3. change a configuration value in admin
  4. magento setup:upgrade

Expected result

  1. config is parsed and loaded into magento

Actual result

  1. parse fails

Format is valid needs update

Most helpful comment

I got past this by changing

'countrycreditcard' => '[]',
to
'countrycreditcard' => [],
in app/etc/config.php
(the array brackets should not be wrapped in quotes)

All 17 comments

@cloverbox, please, provide more details, like errors from exceptions.log, error stack trace, etc. Unfortunately, your description is not enough to understand what is wrong.

@cloverbox, we are closing this issue due to inactivity. If you'd like to update it, please reopen the issue.

I had the same problem recently. Reported error is

Import failed: Warning: Invalid argument supplied for foreach() in /var/www/html/vendor/magento/module-braintree/Model/Adminhtml/System/Config/CountryCreditCard.php on line 70

@magento-engcom-team @joni-jones Can you reopen this please?

We are preparing a pull request to fix this issue.

Me and @DaniloEmpire have created a module to fix this issue:
https://github.com/magespecialist/m2-MSP_FixBraintreeConfig

@bluvertigo I tried this fix but its not working for me. I'm getting the below error while doing setup:upgrade

Plugin class MSP\FixBraintreeConfig\Plugin\Model\Adminhtml\System\Config\CountryCreditCardPlugin doesn't exist

I solved my problem with this issue by manually deleting the sections of the config that cause the failure then manually resetting the Braintree configs

Aside:
It seems your team is using a non standard build chain that has diverged enough from the main branch that you can`t reproduce any of these bugs correctly.

Most of the bugs that are being closed as not reproducible arise by simply installing the default framework and test data ...

I got past this by changing

'countrycreditcard' => '[]',
to
'countrycreditcard' => [],
in app/etc/config.php
(the array brackets should not be wrapped in quotes)

I 'quick-fixed' it by going to /magento/module-braintree/Model/Adminhtml/System/Config/CountryCreditCard.php on line 70 and wrapping

foreach ($value as $data) { ... }

in

if(is_array($value)) { ... }

then I run app:config:import once; removed if; re-run setup:upgrade. Seems to work well for now.

thank you

@al1357 can you confirm whether this will impact the braintree module's functionality at all? I use it in my setup so don't want to try this if it's going to disable use of the module. TIA!

I can tell you that it should not, but if you have a test suite to run
against it I would. I have not had any problems with it but have often and
mysteriously had to manually reconfigure the brain tree settings.

On Mon, Aug 13, 2018 at 2:19 PM, Joshua Flood notifications@github.com
wrote:

@al1357 https://github.com/al1357 can you confirm whether this will
impact the braintree module's functionality at all? I use it in my setup so
don't want to try this if it's going to disable use of the module. TIA!

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/magento/magento2/issues/12298#issuecomment-412614818,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ALhdxOxiC6AcoEhVY1iQPSG-bvM-1PbXks5uQcMkgaJpZM4QgB-G
.

@JoshuaFlood sorry, the module is not is use on our installation so I can't tell.

Does any one knows if this was fixed in further releases ( higher than 2.2.5) ?
We have the same issue with 2.2.5 version

Fix by manually removing quotes
Fix by manually removing quotes has worked for us, but we are not going to do that everytime.

This issue still exists in Magento 2.4.0. Wow.
Please someone reopen this issue and fix it asap. Makes deployment pipelines unusable with magento as you need to import config if you use a separate build server, as it's described in the magento devdocs (https://devdocs.magento.com/guides/v2.4/config-guide/deployment/pipeline/technical-details.html#production-system)

The error is still existing in Magento 2.4.1.
@magento-engcom-team @joni-jones Can you reopen this please?

Can confirm, still exists in 2.4.1
The fix from @SD-dthompson works.

Was this page helpful?
0 / 5 - 0 ratings