Title: PHP 8 Fatal Error on array_filter with custom fields
Last modified: January 26, 2022

---

# PHP 8 Fatal Error on array_filter with custom fields

 *  Resolved [Concept Image](https://wordpress.org/support/users/devci/)
 * (@devci)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/php-8-fatal-error-on-array_filter-with-custom-fields/)
 * Hello,
 * I have this :
    – WordPress 5.8.3 – WooCommerce 6.0.0 – WooCommerce Multilinggual
   4.12.1 – WPML Multilingual CMS 4.4.12 – Advanced Custom Fields PRO 5.11.4 – Advanced
   Custom Fields Multilingual 1.9.3 – PHP 8.0.3
 * I try to translate a WooCommerce product using WooCommerce Multilingual editor.
   
   It works great for most product, but I have the following error on vriable products:`
   Fatal error: Uncaught TypeError: array_filter(): Argument #1 ($array) must be
   of type array, string given in /website_path/wp-content/plugins/woocommerce-multilingual/
   inc/translation-editor/class-wcml-editor-ui-product-job.php on line 606`
 * After looking in plugin code trying to debug, I found this :
    – The error is 
   triggerred when calling $this->add_custom_field_to_element_data() on variations.–“
   add_custom_field_to_element_data” function loop through custom fields, and the
   error is triggered for a custom field created with ACF. This field is not set
   for the variations, it’s only editable on product page, but not specifically 
   for each variation. Is it a problem ? I would like to keep it like this – At 
   this point, check_custom_field_is_single_value() return false because get_custom_field_values()
   return an empty array. All of this because the get_post_meta() is called with
   the variation id and the variation does not have a value for the custom field(
   see previous point)
 * It worked before but with hidden PHP warnings on the production website. We recently
   updated PHP version to PHP 8 and the array_filter error is now a Fatal Error.
   
   Any solution that can help ? Is there a way to avoid WCML looping through some
   field for variations or something ?
 * Kind regards,
    Valentin – Concept Image

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

 *  [diegootgs](https://wordpress.org/support/users/diegootgs/)
 * (@diegootgs)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/php-8-fatal-error-on-array_filter-with-custom-fields/#post-15294689)
 * Hello [@devci](https://wordpress.org/support/users/devci/),
 * Thanks for reporting! Could you please reproduce the issue in this test website?
   [https://tuneful-gong.sandbox.otgs.work/?auto=bgr5T0k1DZKLZfEiU4oJ99n88USBsSbI](https://tuneful-gong.sandbox.otgs.work/?auto=bgr5T0k1DZKLZfEiU4oJ99n88USBsSbI)
 * I will take a look and escalate to our developers after confirming the bug.
 * Regards,
    Diego
 *  [diegootgs](https://wordpress.org/support/users/diegootgs/)
 * (@diegootgs)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/php-8-fatal-error-on-array_filter-with-custom-fields/#post-15294698)
 * Also, are you using the Advanced Translation Editor (ATE)? Could you please check
   if the issue also happens if you use ATE?
 *  Thread Starter [Concept Image](https://wordpress.org/support/users/devci/)
 * (@devci)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/php-8-fatal-error-on-array_filter-with-custom-fields/#post-15302984)
 * Hello,
 * Thanks for the demo website.
 * I achieved to reproduce the bug only once :
    – I created a custom field associated
   to products – I created product attribute and terms – I created a variable product(
   Test product) with variations and filling the custom field – I went to WooCommerce-
   > WooCommerce Multulingual -> I clicked the “+” icon to translate the product
   to spanish and I had a fatal error.
 * When I had this fatal error, I think the ATE was enabled in options.
 * After this, the “+” icon was replaced by an orange gear icon and I could access
   translation from there without problem.
 * I disabled ATE, duplicated the product (Test product (Copy)) and tried to translate
   with the same manipulation but I had no errors.
 * I re-enabled ATE, created another variable product without duplication (new product),
   and again, tried to translate to spannish from WooCommerce Multilingual menu 
   and now I have a WPML error message in BO when I click on the orange gear icon
   to translate “new product”. The error says “WPML didn’t manage to translate this
   page.”, you can see this on the demo website.
 * In addition to that, I made tests with and without ATE on my website, and it 
   didn’t change the problem, I still have the Fatal Error with and without ATE.
 * Also, as said in my previous message, the error that I have on my website is 
   a juste PHP Warning with PHP 7 and a fatal error on PHP 8.
    I saw that the demo
   website you gave me is on PHP 7 with WP_DEBUG set to false. It may be possible
   that the bug occur on the demo website but the warnings are not displayed.
 * Kind regards,
    Valentin – Concept Image
 *  [diegootgs](https://wordpress.org/support/users/diegootgs/)
 * (@diegootgs)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/php-8-fatal-error-on-array_filter-with-custom-fields/#post-15312220)
 * Hi there,
 * Thanks! I think I fixed the issue with ATE on sandbox now using the WPML troubleshooting
   options. I did a quick test with a regular post and it worked correctly.
 * I enabled wp_debug, wp_debug_log and wp_debug_display on the test website. I 
   also added a option to see the debug log from the admin top bar.
 * Could you please check if you are able to reproduce the warning there now? If
   so, please let me know the steps to reproduce. I will download a copy to my local
   server and test it with PHP 8.
 * If you are unable to reproduce on this test install, we may need to do some tests
   using a copy of your website. In this case, could you please create a new ticket
   or chat in our support forum? [https://wpml.org/forums/forum/english-support/](https://wpml.org/forums/forum/english-support/)–
   this is important because we will need to work with sensitive information.
 * Regards,
    Diego
 *  Thread Starter [Concept Image](https://wordpress.org/support/users/devci/)
 * (@devci)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/php-8-fatal-error-on-array_filter-with-custom-fields/#post-15354421)
 * Hello,
 * Sorry for the late reply.
    I can’t access the test website anymore so I can’t
   try to reproduce the warning.
 * My WPML account is configured in french so I’m automatically redirected to french
   WPML support. Do you want me to create it on the english support so that you 
   can take of the new ticket ?
 * Regards,
    Valentin – Concept Image
 *  [diegootgs](https://wordpress.org/support/users/diegootgs/)
 * (@diegootgs)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/php-8-fatal-error-on-array_filter-with-custom-fields/#post-15364574)
 * Hi there,
 * The test sites expires after 7 days of inactivity.
 * Anyway, I think it’s better to go to the support forum, this way we can check
   it using a copy of your website. There is no problem in creating a ticket in 
   french language, you can speak with a french supporter and then they can forward
   to other supporter if needed. It’s also ok if you prefer to speak in English 
   on the French forum, as all our supporters speak English.
 * Regards,
    Diego

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

The topic ‘PHP 8 Fatal Error on array_filter with custom fields’ 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/)

 * 6 replies
 * 2 participants
 * Last reply from: [diegootgs](https://wordpress.org/support/users/diegootgs/)
 * Last activity: [4 years, 3 months ago](https://wordpress.org/support/topic/php-8-fatal-error-on-array_filter-with-custom-fields/#post-15364574)
 * Status: resolved