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

Warning 'Undefined array key "instance"' on plugins that don't define a classname #103

Closed
hostep opened this issue Jul 10, 2023 · 4 comments · Fixed by #104
Closed

Warning 'Undefined array key "instance"' on plugins that don't define a classname #103

hostep opened this issue Jul 10, 2023 · 4 comments · Fixed by #104

Comments

@hostep
Copy link
Contributor

hostep commented Jul 10, 2023

Hi

Saw the following warning block 4 times in the output:

PHP Warning:  Undefined array key "instance" in src/Ampersand/PatchHelper/Checks/ClassPluginPhp.php on line 75

Warning: Undefined array key "instance" in src/Ampersand/PatchHelper/Checks/ClassPluginPhp.php on line 75
PHP Deprecated:  ltrim(): Passing null to parameter #1 ($string) of type string is deprecated in src/Ampersand/PatchHelper/Checks/ClassPluginPhp.php on line 76

Deprecated: ltrim(): Passing null to parameter #1 ($string) of type string is deprecated in src/Ampersand/PatchHelper/Checks/ClassPluginPhp.php on line 76

After outputting the variable $pluginName and searching the codebase for the 4 plugins, I've found them being defined like so in the etc/di.xml file of the Amasty Improved Layered Navigation module (version 2.21.0):

    <type name="Magento\InventoryIndexer\Indexer\Stock\Strategy\Sync">
        <plugin name="configurable_product_full_index" sortOrder="1"/>
        <plugin name="configurable_product_index_list" sortOrder="1"/>
    </type>

    <type name="Magento\InventoryIndexer\Indexer\Stock\Strategy\Sync">
        <plugin name="grouped_product_index_list" sortOrder="2"/>
        <plugin name="grouped_product_index_full" sortOrder="2"/>
    </type>

Notice that these don't contain a type attribute. I'm assuming Amasty defines those like this only to change the sort order of those plugins.

It probably makes sense to add a check like the following before this line I think?

                    if (!isset($pluginConf['instance'])) {
                        continue;
                    }
@convenient
Copy link
Contributor

100% agree @hostep

@hostep
Copy link
Contributor Author

hostep commented Jul 10, 2023

Just one extra tidbit, we have the following modules disabled in the app/etc/config.php file. These modules contain those 4 original definitions:

  • Magento_InventoryConfigurableProductIndexer
  • Magento_InventoryGroupedProductIndexer

This might be part of what is needed to reproduce the problem (not 100% sure though).

Update: indeed, enabling one of those modules, results in 2 fewer warnings being outputted.

@convenient
Copy link
Contributor

That might be the cause of the issue @hostep , possibly if the original config is missing then the merged config won't have this value.

Also I've added a note to https://github.com/AmpersandHQ/ampersand-magento2-upgrade-patch-helper/blob/master/docs/TROUBLESHOOTING.md#debug-a-warning-or-a-notice which may help you in the future

-vvv --php-strict-errors

Should fail loud and fast and clearly on the affected files.

convenient added a commit that referenced this issue Jul 10, 2023
@convenient convenient linked a pull request Jul 10, 2023 that will close this issue
3 tasks
convenient added a commit that referenced this issue Jul 11, 2023
@hostep
Copy link
Contributor Author

hostep commented Jul 11, 2023

Thanks! 🙂

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 a pull request may close this issue.

2 participants