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

Missing Default Config in v7.2.0 Causes PHP Deprecated Error in explode() #88

Open
JkappenFlashpoint opened this issue Feb 7, 2025 · 0 comments

Comments

@JkappenFlashpoint
Copy link

Issue Brief

After updating to Tweakwise Export v7.2.0, the new functionality:

Features:

  • Optionally skip children by Composite Product Type (b648d9a)

introduces errors during feed generation due to the absence of a fallback value for the new config entry tweakwise/export/exclude_child_attributes.

Problem

In Model/Config.php, the following code attempts to explode a config value:

$data = explode(
    ',',
    $this->config->getValue(self::PATH_SKIP_CHILD_BY_COMPOSITE_TYPE, ScopeInterface::SCOPE_STORE, $store)
);

When updating to v7.2.0, there is no default value for this config entry. As a result, when explode is executed on a null value, it triggers a PHP error:

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated

This forces users to manually save the core_config data after updating, which is unintuitive and may lead to unexpected errors if overlooked.


Environment

  • PHP Version: 8.2
  • Magento Version: 2.4.7-p3
  • Magento Enterprise: No
  • Tweakwise Export Version: v7.2.0
  • Magento Deploy Mode: Production
  • Third-party modules: N/A

Steps to Reproduce

  1. Install Magento with the Tweakwise Export v7.1.0 module.
  2. Ensure the Magento shop has some composite-type products (e.g., Configurable or Bundle products).
  3. Upgrade to v7.2.0.
  4. Attempt to generate a product feed without manually saving the config.
  5. Observe the PHP error during execution.

Actual Result

  • A PHP error occurs due to explode() receiving null instead of a string.
Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated

Expected Result

  • The module should provide a fallback value for tweakwise/export/exclude_child_attributes to prevent errors.
  • No manual saving of core_config data should be required after an update.

Suggested Fix

  • Ensure getValue() provides a default value (e.g., an empty string '' or default attributes) before calling explode().
  • Implement a configuration migration script to set a default value during installation.
$data = explode(
    ',',
    $this->config->getValue(self::PATH_SKIP_CHILD_BY_COMPOSITE_TYPE, ScopeInterface::SCOPE_STORE, $store) ?? ''
);

This would prevent the issue and make the upgrade process seamless.

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

No branches or pull requests

1 participant