Skip to content

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

Open
lewisvoncken wants to merge 2 commits intoericthehacker:masterfrom
lewisvoncken:patch-1
Open

[BUGFIX] Solved Missing Configuration because of Illegal string offse…#13
lewisvoncken wants to merge 2 commits intoericthehacker:masterfrom
lewisvoncken:patch-1

Conversation

@lewisvoncken
Copy link
Copy Markdown

…t 'value'

@erikhansen
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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
Copy Markdown

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
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

4 participants