• Resolved Rimas

    (@erku)


    While iterating over various feed types, I noticed that some of them fail to be generated. For example, the “Shopping” feed fails, and the following stack trace is logged into wordpress debug log if logging is enabled:

    0 …/public_html/wp-content/plugins/woocommerce-feed-manager/admin/feed/class-rex-product-feed-shopping.php(177): array_merge()
    1 …/public_html/wp-content/plugins/woocommerce-feed-manager/admin/feed/class-rex-product-feed-shopping.php(121): Rex_Product_Feed_Shopping->add_to_feed()
    2 …/public_html/wp-content/plugins/woocommerce-feed-manager/admin/feed/class-rex-product-feed-shopping.php(28): Rex_Product_Feed_Shopping->generate_product_feed()
    3 …/public_html/wp-content/plugins/woocommerce-feed-manager/admin/class-rex-product-feed-ajax.php(296): Rex_Product_Feed_Shopping->make_feed()
    4 [internal function]: Rex_Product_Feed_Ajax::generate_feed()
    5 …/public_html/wp-content/plugins/woocommerce-feed-manager/vendor/philipnewcomer/wp-ajax-helper/src/components/Utility.php(89): call_user_func_array()
    6 …/public_html/wp-content/plugins/woocommerce-feed-manager/vendor/philipnewcomer/wp-ajax-helper/src/components/Utility.php(57): PhilipNewcomer\WP_Ajax_Helper\Utility::run_callback()
    7 …/public_html/wp-content/plugins/woocommerce-feed-manager/vendor/philipnewcomer/wp-ajax-helper/src/components/Handler.php(109): PhilipNewcomer\WP_Ajax_Helper\Utility::get_callback_response()
    8 …/public_html/wp-includes/class-wp-hook.php(324): PhilipNewcomer\WP_Ajax_Helper\Handler->ajax_handler()
    9 …/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
    10 …/public_html/wp-includes/plugin.php(517): WP_Hook->do_action()
    11 …/public_html/wp-admin/admin-ajax.php(192): do_action() 12 {main}

    The error happens in this line: $value = call_user_func_array('array_merge', $value);. I’ve debugged the problem and it boils down to a change in how PHP8 treats the keys of the second argument to call_user_func_array(): while previously keys were simply ignored, in PHP8, they are treated as names for the newly introduced named arguments.

    A workaround for this would be to use array_values($value) as second argument.

    Another possible option is to replace this hacky-looking call, which something cleaner. I don’t know if that’s indeed the case, but if this call was designed to simply remove the outer level of a potentially multi-level array (as I suspect is the case), a simple call to current() or reset() could be used to achieve that same effect, would look much cleaner, and would not trigger the error above.

    EDIT: both current() and reset() will return false if the array is empty, so for the next line (implode()) to work, you should cover such case as well. For example: $value = reset($value) ?: [];.

    • This topic was modified 1 year, 2 months ago by Rimas.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi,

    Thank you for your detailed analysis and the suggested workaround. We really appreciate your insights into the issue, especially with the changes in PHP8 handling named arguments.

    We’ve reviewed your recommendation, and we can confirm that we are working on implementing a fix for this in an upcoming release.

    We’ll inform you once the release is live. Thanks again for your valuable input!

    Best regards,

    Thread Starter Rimas

    (@erku)

    Great, I’m looking forward to the fixes! Cheers!

    Md Monir Hossain

    (@monircoderex)

    Hi @erku,

    We’re excited to share that we’ve released a new version of the Product Feed Manager, v7.4.26 (2024-12-19). This update includes a fix for the issue.

    Please update your plugin to the latest version at your earliest convenience, and let us know if the issue is resolved for you. We truly value your feedback and want to ensure everything is working as expected on your end.

    Looking forward to hearing from you!

    Best regards,

    Thread Starter Rimas

    (@erku)

    Hi, and thanks for the good news!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Many feed types fail to generate on PHP8’ is closed to new replies.