Title: class-wcml-comments.php error
Last modified: April 18, 2019

---

# class-wcml-comments.php error

 *  Resolved [kolyasapphire](https://wordpress.org/support/users/kolyasapphire/)
 * (@kolyasapphire)
 * [6 years, 12 months ago](https://wordpress.org/support/topic/class-wcml-comments-php-error/)
 * 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](https://wordpress.org/support/users/andrewp-2/)
 * (@andrewp-2)
 * [6 years, 12 months ago](https://wordpress.org/support/topic/class-wcml-comments-php-error/#post-11447248)
 * 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](https://wordpress.org/support/users/kolyasapphire/)
 * (@kolyasapphire)
 * [6 years, 12 months ago](https://wordpress.org/support/topic/class-wcml-comments-php-error/#post-11447368)
 * 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
 *  [George Botsev](https://wordpress.org/support/users/botzev/)
 * (@botzev)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/class-wcml-comments-php-error/#post-11453902)
 * 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](https://wordpress.org/support/users/kolyasapphire/)
 * (@kolyasapphire)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/class-wcml-comments-php-error/#post-11454363)
 * 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](https://wordpress.org/support/users/kolyasapphire/)
 * (@kolyasapphire)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/class-wcml-comments-php-error/#post-11454478)
 * 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.
 *  [George Botsev](https://wordpress.org/support/users/botzev/)
 * (@botzev)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/class-wcml-comments-php-error/#post-11456653)
 * 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](https://wordpress.org/support/users/kolyasapphire/)
 * (@kolyasapphire)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/class-wcml-comments-php-error/#post-11459450)
 * 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.
 *  [George Botsev](https://wordpress.org/support/users/botzev/)
 * (@botzev)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/class-wcml-comments-php-error/#post-11461220)
 * 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](https://wordpress.org/support/users/kolyasapphire/)
 * (@kolyasapphire)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/class-wcml-comments-php-error/#post-11467427)
 * Great! Thank you

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

The topic ‘class-wcml-comments.php error’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce-multilingual/assets/icon-256x256.png?rev=2937122)
 * [WPML Multilingual & Multicurrency for WooCommerce](https://wordpress.org/plugins/woocommerce-multilingual/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-multilingual/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-multilingual/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-multilingual/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-multilingual/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-multilingual/reviews/)

 * 9 replies
 * 3 participants
 * Last reply from: [kolyasapphire](https://wordpress.org/support/users/kolyasapphire/)
 * Last activity: [6 years, 11 months ago](https://wordpress.org/support/topic/class-wcml-comments-php-error/#post-11467427)
 * Status: resolved