Skip Navigation

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

Problem:

If you're experiencing a fatal error (like the following) when attempting to add a translation using the Classic / WordPress editor, and the error message indicates a type error with

in_array()

function where the second argument must be of type array but bool is given, this might be due to corrupt entries in your database.

Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, bool given in (...)/wp-content/plugins/sitepress-multilingual-cms/classes/menu-elements/class-wpml-admin-scripts-setup.php:143

Solution:

We recommend trying the following steps after ensuring you have a backup of your site:

1. Navigate to All Posts.
2. Change the language to French using the Dashboard language switcher at the top header.
3. Quick edit any single post and set it as a sticky post, then revert the changes. This action will create necessary entries in the database to potentially fix the issue.
4. Attempt to translate the posts again using the WPML Classic Editor.

This issue is related to known issues which can be found here:

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. Additionally, please feel free to open a new support ticket for further assistance at WPML Support Forum.

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 2 replies, has 0 voices.

Last updated by Kristoff 3 months, 2 weeks ago.

Assisted by: Bigul.

Author Posts
February 5, 2025 at 3:21 pm #16671867

Kristoff

Background of the issue:
I am trying to add a translation using the Classic / WordPress editor. I navigated from wp-admin/post.php?post=1403&action=edit&lang=en to /wp-admin/post-new.php?lang=fr&post_type=post&trid=642&source_lang=en. The complete error returned is:

Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, bool given in (...)/wp-content/plugins/sitepress-multilingual-cms/classes/menu-elements/class-wpml-admin-scripts-setup.php:143 Stack trace: #0 (...)/wp-content/plugins/sitepress-multilingual-cms/classes/menu-elements/class-wpml-admin-scripts-setup.php(143): in_array('1403', false) #1 (...)/wp-includes/class-wp-hook.php(324): WPML_Admin_Scripts_Setup->wpml_js_scripts_setup('') #2 (...)/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array) #3 (...) [CONTINUED] #7 {main} thrown in (...)/wp-content/plugins/sitepress-multilingual-cms/classes/menu-elements/class-wpml-admin-scripts-setup.php on line 143

.

Symptoms:
I encountered a fatal error when attempting to add a translation using the Classic / WordPress editor. The error message is: Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, bool given.

Questions:
This is not at all what I wrote. Why would you do this?

Both dev and staging envs
Tried different PHP versions and themes

February 5, 2025 at 5:10 pm #16672448

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

Welcome to the WPML support forum. I will do my best to help you to resolve the issue.

In the past, we had a similar fatal error while using the PHP 8.0 version. But it is fixed now.

Please try the following steps after a full site backup and make sure the bug exists or not.

1) Increase *WP Memory Limit* to *256*(the minimum required memory limit for WPML is *128*). Please check the following links for more details

https://wpml.org/home/minimum-requirements/

https://wordpress.org/support/article/editing-wp-config-php/#increasing-memory-allocated-to-php

2) Increase the *MaxInputVars* of PHP settings to *10000*. Please check the following article for more details or contact your system admin/hosting provider for this purpose.

hidden link

3) Upgrade WPML Multilingual CMS to the 4.6.15 version

4) Upgrade String Translation to the 3.2.18 version

--
Thanks!

Bigul

February 6, 2025 at 11:13 am #16674926

Kristoff

All done. The issue persists.

{"core":{"Wordpress":{"Multisite":"No","SiteURL":"https:\/\/claytonsegura.local","HomeURL":"https:\/\/claytonsegura.local","Version":"6.7.1","PermalinkStructure":"\/%postname%\/","PostTypes":"post, page, attachment, revision, nav_menu_item, custom_css, customize_changeset, oembed_cache, user_request, wp_block, wp_template, wp_template_part, wp_global_styles, wp_navigation, wp_font_family, wp_font_face, acf-taxonomy, acf-post-type, acf-ui-options-page, acf-field-group, acf-field, singlesnip","PostStatus":"publish, future, draft, pending, private, trash, auto-draft, inherit, request-pending, request-confirmed, request-failed, request-completed, acf-disabled","RestEnabled":"No"},"Server":{"jQueryVersion":"3.7.1","PHPVersion":"8.1.13","MySQLVersion":"5.7.39","ServerSoftware":"Apache\/2.4.54 (Unix) mod_fastcgi\/mod_fastcgi-SNAP-0910052141 OpenSSL\/1.0.2u mod_wsgi\/3.5 Python\/2.7.18"},"PHP":{"MemoryLimit":"2G","WP Memory Limit":"40M","UploadMax":"1G","PostMax":"1G","TimeLimit":"7200","MaxInputVars":"1000","MBString":true,"libxml":true}},"plugins":{"active_plugins":{"gravityforms\/gravityforms.php":{"Plugin Slug":"","Name":"Gravity Forms","PluginURI":"https:\/\/gravityforms.com","Version":"2.9.2","Author":"Gravity Forms","AuthorURI":"https:\/\/gravityforms.com","TextDomain":"gravityforms","DomainPath":"\/languages","Network":false,"RequiresWP":"4.0","RequiresPHP":"5.6","UpdateURI":"","RequiresPlugins":"","Title":"Gravity Forms","AuthorName":"Gravity Forms"},"sitepress-multilingual-cms\/sitepress.php":{"Plugin Slug":"sitepress-multilingual-cms","Name":"WPML Multilingual CMS","PluginURI":"https:\/\/wpml.org\/","Version":"4.6.15","Author":"OnTheGoSystems","AuthorURI":"http:\/\/www.onthegosystems.com\/","TextDomain":"sitepress-multilingual-cms","DomainPath":"","Network":false,"RequiresWP":"","RequiresPHP":"","UpdateURI":"","RequiresPlugins":"","Title":"WPML Multilingual CMS","AuthorName":"OnTheGoSystems"},"advanced-custom-fields-pro\/acf.php":{"Plugin Slug":"","Name":"Advanced Custom Fields PRO","PluginURI":"https:\/\/www.advancedcustomfields.com","Version":"6.3.11","Author":"WP Engine","AuthorURI":"https:\/\/wpengine.com\/?utm_source=wordpress.org\u0026utm_medium=referral\u0026utm_campaign=plugin_directory\u0026utm_content=advanced_custom_fields","TextDomain":"acf","DomainPath":"\/lang","Network":false,"RequiresWP":"6.0","RequiresPHP":"7.4","UpdateURI":"false","RequiresPlugins":"","Title":"Advanced Custom Fields PRO","AuthorName":"WP Engine"},"regenerate-thumbnails\/regenerate-thumbnails.php":{"Plugin Slug":"","Name":"Regenerate Thumbnails","PluginURI":"https:\/\/alex.blog\/wordpress-plugins\/regenerate-thumbnails\/","Version":"3.1.6","Author":"Alex Mills (Viper007Bond)","AuthorURI":"https:\/\/alex.blog\/","TextDomain":"regenerate-thumbnails","DomainPath":"","Network":false,"RequiresWP":"","RequiresPHP":"","UpdateURI":"","RequiresPlugins":"","Title":"Regenerate Thumbnails","AuthorName":"Alex Mills (Viper007Bond)"},"wp-migrate-db-pro\/wp-migrate-db-pro.php":{"Plugin Slug":"","Name":"WP Migrate","PluginURI":"https:\/\/deliciousbrains.com\/wp-migrate-db-pro\/","Version":"2.7.0","Author":"WP Engine","AuthorURI":"https:\/\/deliciousbrains.com","TextDomain":"wp-migrate-db","DomainPath":"\/languages\/","Network":true,"RequiresWP":"","RequiresPHP":"","UpdateURI":"https:\/\/deliciousbrains.com\/wp-migrate-db-pro\/","RequiresPlugins":"","Title":"WP Migrate","AuthorName":"WP Engine"},"wpml-string-translation\/plugin.php":{"Plugin Slug":"wpml-string-translation","Name":"WPML String Translation","PluginURI":"https:\/\/wpml.org\/","Version":"3.2.18","Author":"OnTheGoSystems","AuthorURI":"http:\/\/www.onthegosystems.com\/","TextDomain":"wpml-string-translation","DomainPath":"","Network":false,"RequiresWP":"","RequiresPHP":"","UpdateURI":"","RequiresPlugins":"","Title":"WPML String Translation","AuthorName":"OnTheGoSystems"}},"mu_plugins":{"wp-migrate-db-pro-compatibility.php":{"Plugin Slug":"","Name":"WP Migrate Compatibility","PluginURI":"http:\/\/deliciousbrains.com\/wp-migrate-db-pro\/","Version":"1.3","Description":"Prevents 3rd party plugins from being loaded during WP Migrate DB specific operations","Author":"Delicious Brains","AuthorURI":"http:\/\/deliciousbrains.com","TextDomain":"","DomainPath":"","Network":false,"RequiresWP":"","RequiresPHP":"","UpdateURI":"","RequiresPlugins":"","Title":"WP Migrate Compatibility","AuthorName":"Delicious Brains"}},"dropins":[]},"theme":{"Name":"The Theme for C\u0026amp;S","ThemeURI":false,"Author":"","AuthorURI":"","Template":"","Version":"2.1.1","TextDomain":"thetheme","DomainPath":"","ParentName":""},"extra-debug":{"WPML":{"hide_upgrade_notice":"4.6.11","translated_document_status_sync":"1","icl_capabilities_verified":true,"active_languages":["en","fr"],"interview_translators":1,"existing_content_language_verified":1,"language_negotiation_type":1,"icl_lso_link_empty":0,"sync_page_ordering":1,"sync_page_parent":1,"sync_page_template":1,"sync_ping_status":1,"sync_comment_status":1,"sync_sticky_flag":1,"sync_password":1,"sync_private_flag":1,"sync_post_format":1,"sync_delete":1,"sync_delete_tax":1,"sync_post_taxonomies":1,"sync_post_date":1,"sync_taxonomy_parents":0,"translation_pickup_method":0,"notify_complete":1,"translated_document_status":"1","remote_management":0,"auto_adjust_ids":1,"alert_delay":0,"promote_wpml":0,"automatic_redirect":0,"remember_language":24,"icl_lang_sel_copy_parameters":"","translated_document_page_url":"auto-generate","sync_comments_on_duplicates":0,"seo":{"head_langs":1,"canonicalization_duplicates":1,"head_langs_priority":1},"posts_slug_translation":{"on":1,"string_name_migrated":true},"urls":{"directory_for_default_language":0,"show_on_root":"","root_html_file_path":"","root_page":0,"hide_language_switchers":1},"xdomain_data":1,"custom_posts_sync_option":{"post":1,"page":1,"attachment":1,"wp_block":1,"wp_navigation":1,"wp_template":1,"wp_template_part":1,"acf-post-type":0,"acf-taxonomy":0,"acf-ui-options-page":0},"taxonomies_sync_option":{"category":1,"post_tag":1,"translation_priority":1,"wp_theme":0},"tm_block_retranslating_terms":"1","admin_default_language":"_default_","ajx_health_checked":true,"languages_order":["en","fr"],"theme_language_folders":null,"st":{"db_ok_for_gettext_context":true,"WPML_ST_Upgrade_Migrate_Originals_has_run":true,"WPML_ST_Upgrade_Display_Strings_Scan_Notices_has_run":true,"WPML_ST_Upgrade_DB_String_Packages_2.4.2_has_run":true,"WPML_ST_Upgrade_MO_Scanning_4_has_run":true,"WPML_ST_Upgrade_DB_String_Name_Index_2_has_run":true,"WPML_ST_Upgrade_DB_Longtext_String_Value_has_run":true,"WPML_ST_Upgrade_DB_Strings_Add_Translation_Priority_Field_has_run":true,"WPML_ST_Upgrade_DB_String_Packages_Word_Count_has_run":true,"WPML\\ST\\MO\\Generate\\Process\\Status_background_has_run":true,"WPML\\ST\\Upgrade\\Command\\RegenerateMoFilesWithStringNames_has_run":true,"WPML\\ST\\Upgrade\\Command\\MigrateMultilingualWidgets_has_run":true,"WPML\\ST\\MO\\Generate\\Process\\Status_has_run":true,"strings_per_page":10,"icl_st_auto_reg":"disable","strings_language":"en","translated-users":[],"sw":[]},"default_categories":{"en":"1","fr":22},"default_language":"en","setup_wizard_step":3,"dont_show_help_admin_notice":true,"store_frontend_cookie":1,"setup_complete":1,"translation-management":{"custom_fields_translation":{"title":2,"description":2,"keywords":2,"_edit_last":0,"_edit_lock":0,"_wp_page_template":0,"_wp_attachment_metadata":0,"original_post_id":0,"_wpml_original_post_id":0,"_wp_old_slug":0,"_icl_translator_note":0,"_alp_processed":0,"_pingme":0,"_encloseme":0,"_icl_lang_duplicate_of":0,"_thumbnail_id":0,"_wp_attached_file":0,"_wp_attachment_image_alt":2,"footnotes":2},"custom_fields_readonly_config":["title","description","keywords","_edit_last","_edit_lock","_wp_page_template","_wp_attachment_metadata","original_post_id","_wpml_original_post_id","_wp_old_slug","_icl_translator_note","_alp_processed","_pingme","_encloseme","_icl_lang_duplicate_of","_thumbnail_id","_wp_attached_file","_wp_attachment_image_alt","footnotes"],"custom_fields_translation_custom":[],"custom_fields_translation_custom_readonly":[],"doc_translation_method":"1","__custom_types_readonly_config_prev":[],"custom_types_readonly_config":[],"__custom_fields_readonly_config_prev":["title","description","keywords","_edit_last","_edit_lock","_wp_page_template","_wp_attachment_metadata","original_post_id","_wpml_original_post_id","_wp_old_slug","_icl_translator_note","_alp_processed","_pingme","_encloseme","_icl_lang_duplicate_of","_thumbnail_id","_wp_attached_file","_wp_attachment_image_alt","footnotes"],"__custom_term_fields_readonly_config_prev":[],"custom_term_fields_readonly_config":[],"custom_fields_encoding":{"footnotes":"json"},"custom_fields_attributes_whitelist":{"footnotes":{"*":{"content":[]}}},"taxonomies_readonly_config":{"translation_priority":1,"wp_theme":0},"custom-types_readonly_config":{"attachment":1,"wp_block":1,"wp_navigation":1,"wp_template":1,"wp_template_part":1,"acf-post-type":0,"acf-taxonomy":0,"acf-ui-options-page":0}},"custom-types_sync_option":{"attachment":1,"wp_block":1,"wp_navigation":1,"wp_template":1,"wp_template_part":1,"acf-post-type":0,"acf-taxonomy":0,"acf-ui-options-page":0},"language_selector_initialized":1,"xliff_newlines":2,"tm_xliff_version":"12","site_does_not_use_icl":true,"doc_translation_method":"1"},"installer":{"version":"3.1.7","repositories":{"wpml":{"api-url":"https:\/\/api.wpml.org\/","bucket-url":"https:\/\/cdn.wpml.org\/wpml-bucket-49.json","subscription":{"key":"BYQpFoMkCA","key_type":1,"data":{"subscription_type":6721,"expires":null,"status":"1","notes":"","order_id":"601145","hasAutoRenewal":true},"registered_by":1,"site_url":"https:\/\/claytonsegura.local"},"last-successful-subscription-fetch":"2025-02-06 11:09:40"},"toolset":{"api-url":"https:\/\/api.toolset.com\/","bucket-url":"not assigned","subscription":"","last-successful-subscription-fetch":"none"}},"instances":{"\/Users\/kristoffbertram\/Development\/claytonsegura-com\/public\/wp-content\/plugins\/sitepress-multilingual-cms\/vendor\/otgs\/installer\/installer.php":{"bootfile":"\/Users\/kristoffbertram\/Development\/claytonsegura-com\/public\/wp-content\/plugins\/sitepress-multilingual-cms\/vendor\/otgs\/installer\/installer.php","version":"3.1.7","args":{"plugins_install_tab":1,"site_key_nags":[{"repository_id":"wpml","product_name":"WPML","condition_cb":[{"wpdb":{"show_errors":true,"suppress_errors":false,"last_error":"","num_queries":99,"num_rows":0,"rows_affected":0,"insert_id":0,"last_query":"SELECT option_value FROM wp_options WHERE option_name = \u0027auto_core_update_failed\u0027 LIMIT 1","last_result":[],"queries":null,"prefix":"wp_","base_prefix":"wp_","ready":true,"blogid":0,"siteid":0,"tables":["posts","comments","links","options","postmeta","terms","term_taxonomy","term_relationships","termmeta","commentmeta"],"old_tables":["categories","post2cat","link2cat"],"global_tables":["users","usermeta"],"ms_global_tables":["blogs","blogmeta","signups","site","sitemeta","registration_log"],"old_ms_global_tables":["sitecategories"],"comments":"wp_comments","commentmeta":"wp_commentmeta","links":"wp_links","options":"wp_options","postmeta":"wp_postmeta","posts":"wp_posts","terms":"wp_terms","term_relationships":"wp_term_relationships","term_taxonomy":"wp_term_taxonomy","termmeta":"wp_termmeta","usermeta":"wp_usermeta","users":"wp_users","blogs":null,"blogmeta":null,"registration_log":null,"signups":null,"site":null,"sitecategories":null,"sitemeta":null,"field_types":{"post_author":"%d","post_parent":"%d","menu_order":"%d","term_id":"%d","term_group":"%d","term_taxonomy_id":"%d","parent":"%d","count":"%d","object_id":"%d","term_order":"%d","ID":"%d","comment_ID":"%d","comment_post_ID":"%d","comment_parent":"%d","user_id":"%d","link_id":"%d","link_owner":"%d","link_rating":"%d","option_id":"%d","blog_id":"%d","meta_id":"%d","post_id":"%d","user_status":"%d","umeta_id":"%d","comment_karma":"%d","comment_count":"%d","active":"%d","cat_id":"%d","deleted":"%d","lang_id":"%d","mature":"%d","public":"%d","site_id":"%d","spam":"%d"},"charset":"utf8mb4","collate":"utf8mb4_unicode_520_ci","func_call":"$db-\u003Equery(\u0022SELECT option_value FROM wp_options WHERE option_name = \u0027auto_core_update_failed\u0027 LIMIT 1\u0022)","is_mysql":true,"time_start":null,"error":null,"categories":"wp_categories","post2cat":"wp_post2cat","link2cat":"wp_link2cat"},"locale_utils":{},"footer_preview":false,"icl_translations_cache":null,"icl_language_name_cache":{},"icl_term_taxonomy_cache":null,"ROOT_URL_PAGE_ID":null},"setup"]}]},"delegated":true}}}}}
February 6, 2025 at 4:17 pm #16676473

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

Thank you for the updates. A couple of requests for tracking the issue.

1) Please share the URL of couple of posts/pages having the issue while saving the translation

2) Please fill in the private details fields after a full site backup. I would like to access the admin area of your site for further checking. Refer to the following links for more details about our private information sharing policies.

https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/

hidden link

--
Thanks!

Bigul

February 7, 2025 at 4:23 pm #16680622

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

Thank you for the site credentials. I can also reproduce the issue with a new post. It may be a compatibility issue and requires further testing.

So please allow me to make a duplicate copy of your site using the Duplicator plugin (https://wordpress.org/plugins/duplicator/) to debug the issue on our local server.

--
Thanks!

Bigul

February 7, 2025 at 6:58 pm #16681117

Kristoff

Go right ahead Bigul. Thank you for your commitment to getting this resolved!

February 10, 2025 at 10:07 am #16686170

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

Thank you for the permission. I made a copy of the site. The bug exists in my local copy after the initial troubleshooting procedures. So I am consulting with our team for an expert opinion. We will get back to you as early as possible. Please wait.

--
Thanks!

Bigul

February 17, 2025 at 8:48 am #16712220

Kristoff

Hi Bigul, any updates on this? Thank you!

February 17, 2025 at 11:05 am #16713440

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

We have a workaround for this bug. Please try the following steps after a site backup and make sure the problem exists or not.

- Go to All Posts
- Change the language to French (via the Dashboard language switcher of the top header)
- Quick edit any single post and set it as a sticky post, then revert the changes. This will create entries in the database to fix the issue.
- Try to translate the posts

It looks like this one is related to the following known issue.

https://wpml.org/errata/php8-uncaught-typeerror-array_merge-argument-1-must-be-of-type-array-bool-given-in/

https://wpml.org/forums/topic/the-translations-for-a-certain-elementor-tempalte-are-not-being-saved/

--
Thanks!

Bigul

February 17, 2025 at 1:37 pm #16714643

Kristoff

I'm not sure how to apply this fix, Bigul.
Right now, having created an English (source) copy, and failing on the translation option, will prevent an FR post from being created (and thus I can't set it to sticky.)

February 17, 2025 at 2:08 pm #16714875

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

Thank you for the updates. Please note that the following steps are a single time action. It will help us to clear the corrupt entries from the database.


- Go to All Posts
- Change the language to French (via the Dashboard language switcher of the top header)
- Quick edit any single post and set it as a sticky post, then revert the changes. This will create entries in the database to fix the issue.

After this, we can translate any posts using WPML Classic Editor and manually from WordPress Editor.

So please try it and let us know your feedback.

--
Thanks!

Bigul

February 18, 2025 at 11:55 am #16718612

Kristoff

That did it! Thank you for your patience and help, Bigul! All the best to you and your team!