• Resolved kolyasapphire

    (@kolyasapphire)


    Hi!

    I’m getting this error in logs:
    PHP Warning: Invalid argument supplied for foreach() in /wp-content/plugins/woocommerce-multilingual/inc/class-wcml-comments.php on line 75

    But on line 74 there is a check if ( $ratings ) even exists, which should not for this product as there are no reviews, therefore no ratings.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor Andreas Panag

    (@andrewp-2)

    Thank you very much for your ticket!

    Can I ask you please to provide exactly steps for reproducing this issue, because I am unable to see this warning.

    Looking forward for your reply!

    Thread Starter kolyasapphire

    (@kolyasapphire)

    Hi Andreas!

    I actually can’t reproduce it myself, this product has no reviews and no ratings. However, in the database there is a meta entry for ratings, but it’s serialized and empty inside. Could this be somehow making the if check return true instead of false? That’s the only idea I have

    Hello!
    What do you mean by “Serialized and empty inside”?
    As far as I see the code, we try to get the contents of the keys _wc_rating_count for ratings and that can be the issue that you have on line 76 – if there is a post with broken serialization or invalid data in that key.
    I suggest that you copy the value from the original post in the translation.
    Since the product has no ratings or reviews that should not be a problem I believe.

    Thread Starter kolyasapphire

    (@kolyasapphire)

    Hi!

    It seems the metadata for second language version of the product is broken, it’s not valid serialized data, copying a:0:{} to it fixed the issue.

    It appears that even when loading the primary language of the product plugin queries ratings in all languages, triggering the error.

    Thread Starter kolyasapphire

    (@kolyasapphire)

    A bunch of products have meta value s:1:”1″; for meta key _wc_rating_count. As I understand that’s incorrect. A proper format would be something like a:1:{i:5;i:1;} which is one rating of 5 stars.

    If you have corrupt values even in the original, then perhaps you should remove these keys and thus avoid any errors that are triggered.

    Do you have a way of reproducing the wrong malformed values?
    Have you perhaps migrated your site recently? This sometimes is known to cause issues with serialized fields sometimes (if not done properly).

    Thread Starter kolyasapphire

    (@kolyasapphire)

    No, just the second language versions. If it was a migration issue original ones would be malformed too.

    My method worked, not getting any more errors. As a precaution it would great if plugin checked the database for corrupted values, example in previous message.

    Thank you for your suggestion.
    I will report that to our developers and create a ticket in our internal bugtracking system so that they can fix it.

    Thread Starter kolyasapphire

    (@kolyasapphire)

    Great! Thank you

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘class-wcml-comments.php error’ is closed to new replies.