Skip to content Skip to sidebar

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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: America/Argentina/Buenos_Aires (GMT-03:00)

Tagged: 

This topic contains 5 replies, has 1 voice.

Last updated by Otto 1 month ago.

Assisted by: Otto.

Author Posts
November 12, 2025 at 4:11 pm #17571837

Jan

Background of the issue:
I am trying to run an import script, but it fails every time. The script throws a fatal error related to the array_filter function. The error message is: 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:463. According to the get_post_meta documentation, false will be returned for invalid post_ids and should be handled accordingly to prevent 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?

I have implemented my own workaround, which functions, changing the line 463 to:
$custom_fields_values = array_values( array_filter( get_post_meta( $post->ID, $key ) ?: [] ) );
I would request for you to implement this.

In an earlier ticket, you responded with the request to use the 'delete all ghost items' on your troubleshooting page. This does not fix the issue for me, unfortunately.

November 12, 2025 at 4:13 pm #17571853

Jan

Maybe I'm confused by the UI and this message is not necessary, but I still need support.

November 13, 2025 at 2:36 pm #17575426

Otto
WPML Supporter since 09/2015

Languages: English (English ) Spanish (Español )

Timezone: America/Argentina/Buenos_Aires (GMT-03:00)

Hello,

Thanks for the report.

I escalated the issue to our second tier support, I'll keep you posted.

Best Regards,
Otto

November 13, 2025 at 7:48 pm #17576679

Otto
WPML Supporter since 09/2015

Languages: English (English ) Spanish (Español )

Timezone: America/Argentina/Buenos_Aires (GMT-03:00)

Hello,

From our second tier support:

This is very odd.
Normally the function \WPML_Element_Translation_Package::add_custom_field_contents takes a post that already exists and generates a package based on its meta fields.
In that sense, get_post_meta will never return false, because the post is supposed to exist at this point and hence the ID won't be invalid.
I understand that a defensive fix would solve this, but I feel that there might be something more here to the case and I would feel better we can have a package and to trace the issue.

Can you please provide us with a copy of your site so we can take a deeper look? In case you do, I enable a private reply so you can share safely a download link. A copy of the DB and the wp-content folder (excluding uploads) will do or you can use “Duplicator” or "All in One WP Migration" plugins.

Thanks for your cooperation.

Best Regards,
Otto

November 17, 2025 at 9:47 am #17583014

Jan

I'm sorry, I cannot provide you with a copy of the site at this point in time. I feel that the defensive fix would be very much appreciated though.

I found a similar issue a while back, but I'm not sure if there was any solution applied there:
https://wpml.org/forums/topic/array_filter-argument-1-array-must-be-of-type-array-false-given/

November 17, 2025 at 1:49 pm #17584376

Otto
WPML Supporter since 09/2015

Languages: English (English ) Spanish (Español )

Timezone: America/Argentina/Buenos_Aires (GMT-03:00)

Hello,

Thanks.

No, that ticket got closed without any further activity.

If we provide a testing environment, is it possible for you to help us run the script there so we can reproduce the issue and take a deeper look?

Best Regards,
Otto

The topic ‘[Closed] Fatal error during import’ is closed to new replies.