Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Solved Missing Configuration because of Illegal string offse… #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lewisvoncken
Copy link

…t 'value'

@erikhansen
Copy link
Collaborator

@lewisvoncken Using PHP's error suppression is typically not recommended.

I'm not exactly sure why that error is getting triggered as I don't have steps to reproduce, but I'm guessing it's because the $option variable is not an array, and the code is assuming it is. If that's the case, here is one way you could handle it more elegantly:

if (isset($option['value'])) {
    $optionsByValue[$option['value']] = $option;
}

@rubenexp
Copy link

Hi Erik,

I'm currently experiencing the same error. You're correct it's because the $option variable is not an array. It's a Phrase object in this case. The error seems to occur only in Commerce. I'm on 2.2.4, the errors occurs on the field catalog/magento_catalogpermissions/grant_catalog_product_price.

Your proposed fix does not work if it's a Phrase object, the fix below does.

if (is_array($option)) {
    $optionsByValue[$option['value']] = $option;
}

@erikhansen
Copy link
Collaborator

@rubenexp Can you provide detailed steps to reproduce this issue? I'm not able to on a Magento 2.2.3 Commerce site. I tested on an environment running in both development mode and production mode.

magento admin-wuadj

@rubenexp
Copy link

rubenexp commented Dec 4, 2018

@erikhansen I think it's related to different scope settings.

  1. 'Display Product Prices' option is set to 'No' on scope 'Default config',
  2. Change scope to website level
  3. Set 'Display Product Prices' option is set to 'Yes, for everyone' on website scope level
  4. Change scope back to scope 'Default config'
  5. If not already there, navigate to the Stores > Configuration > Catalog > Catalog page, the exception is immediately thrown when scope is 'Default Config'. When it's on website level, everything works.

Maybe this only occurs in 2.2.4, I don't have the option atm to test this on 2.2.3 myself.

@jean-bernard-valentaten
Copy link

jean-bernard-valentaten commented Apr 2, 2019

If I may intervene, I just had the exact same issue. This only occurs when Magento B2B Extension is installed as at least one of the source models used in one of the B2B modules implements a source model that does not return the expected array structure.
I have a fix for this as can be seen in PR #15.

@lewisvoncken
Copy link
Author

Hi Erik,

I'm currently experiencing the same error. You're correct it's because the $option variable is not an array. It's a Phrase object in this case. The error seems to occur only in Commerce. I'm on 2.2.4, the errors occurs on the field catalog/magento_catalogpermissions/grant_catalog_product_price.

Your proposed fix does not work if it's a Phrase object, the fix below does.

if (is_array($option)) {
    $optionsByValue[$option['value']] = $option;
}

This has been changed

@erikhansen
Copy link
Collaborator

For the record, I just ran into this error after configuring the TaxJar extension at different scopes:

Exception #0 (Exception): Warning: Illegal offset type in /var/www/html/vendor/ericthehacker/magento2-configscopehints/Helper/Data.php on line 118

This fix in this PR didn't solve the problem, as I had to slightly tweak it:

Before:

                if (isset($option['value'])) {
                    $optionsByValue[$option['value']] = $option;
                }

After:

                if (isset($option['value']) && !is_array($option['value'])) {
                    $optionsByValue[$option['value']] = $option;
                }

@lewisvoncken
Copy link
Author

@erikhansen
please take a look at the fork: https://github.com/experius/magento2-configscopehints

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants