Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
You are encountering a persistent issue with an import script that fails every time it runs, throwing a Fatal error: Uncaught TypeError: array_filter(): Argument #1 ($array) must be of type array, false given. This occurs due to the script receiving a false value from

get_post_meta

when an invalid post_id is used.
Solution:
We recommend trying the following steps to potentially resolve the issue:
1. Ensure you take a backup of your site's database.
2. Navigate to WPML -> Support -> Troubleshooting.
3. On the troubleshooting screen, press 'Remove ghost entries from the translation tables'.
*** Please backup your database before using this.***

If this solution does not resolve your issue or seems irrelevant due to being outdated or not applicable to your case, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the problem persists, please open a new support ticket.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by Itamar 9 months, 2 weeks ago.

Assisted by: Itamar.

Author Posts
August 19, 2024 at 12:31 pm #16083437

peterP-63

Background of the issue:
I am encountering a persistent issue with an import script that fails every time it runs. The script throws the following error: Fatal error: Uncaught TypeError: array_filter(): Argument #1 ($array) must be of type array, false given in wp-content/plugins/sitepress-multilingual-cms/classes/translation-jobs/class-wpml-element-translation-package.php:319. As a current workaround, we patched the above line with the following code:

$custom_fields_values = array_values( array_filter( get_post_meta( $post->ID, $key ) ?? [] ) );

. According to the get_post_meta documentation, false will be returned for invalid post_ids and is therefore a (somewhat) valid response from `get_post_meta` should be handled accordingly and not result in a fatal error.

Symptoms:
The import script fails every time it runs, throwing a Fatal error: Uncaught TypeError: array_filter(): Argument #1 ($array) must be of type array, false given.

Questions:
Why does the import script fail with the error: array_filter(): Argument #1 ($array) must be of type array, false given?
Is the workaround provided a valid solution to handle the false return value from get_post_meta?

August 19, 2024 at 7:25 pm #16085074

Itamar
WPML Supporter since 02/2016

Languages: English (English )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi,

I'm consulting our second-tier supporters about your case and will update you once I have their reply.

Meanwhile, can you please add more information about this import script you are using?
Is it related to any of the plugins on your site?

Regards,
Itamar.

August 20, 2024 at 6:17 am #16085698

peterP-63

Hi,

The import script transfers data from my inventory management system to WordPress and WooCommerce. It synchronizes product information, stock levels, and other relevant data between the systems to ensure that my online store is up-to-date with the latest inventory details.

Regards,
Peter

August 20, 2024 at 7:09 am #16085792

Itamar
WPML Supporter since 02/2016

Languages: English (English )

Timezone: Asia/Jerusalem (GMT+03:00)

Thanks, Peter.

I've passed this information on to our second-tier supporters, and I'm still waiting for their reply.

I appreciate your patience.
Itamar.

August 21, 2024 at 9:44 am #16089534

Itamar
WPML Supporter since 02/2016

Languages: English (English )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi,

Our second-tier supporter suggests you try WPML's troubleshooting section as a workaround. Here is what you need to do.

1. Take a backup of the DB of your site.

2. Go to WPML -> Support -> Troubleshooting (link)

3. Once on the troubleshooting screen, press the following buttons and check if it helps.

- 'Remove ghost entries from the translation tables'

*** Please backup your database before using this.***

Regards,
Itamar.