Roxanne Rollin
Background of the issue:
We are getting an error on our website coming from the WPML plugin. I was attempting to perform some actions related to post translations. Here is the stack trace:
[04-Jun-2024 14:08:18 UTC] PHP Fatal error: Uncaught TypeError: array_filter(): Argument #1 ($array) must be of type array, bool given in /wp-content/plugins/sitepress-multilingual-cms/classes/translation-jobs/class-wpml-element-translation-package.php:319
Stack trace:
#0 /wp-content/plugins/sitepress-multilingual-cms/classes/translation-jobs/class-wpml-element-translation-package.php(319): array_filter(false)
#1 /wp-content/plugins/sitepress-multilingual-cms/classes/translation-jobs/class-wpml-element-translation-package.php(88): WPML_Element_Translation_Package->add_custom_field_contents(Array, NULL, Array, Array)
#2 /wp-content/plugins/sitepress-multilingual-cms/inc/actions/wpml-tm-action-helper.class.php(13): WPML_Element_Translation_Package->create_translation_package(NULL)
#3 /wp-content/plugins/sitepress-multilingual-cms/inc/actions/wpml-tm-post-actions.class.php(72): WPML_TM_Action_Helper->create_translation_package('125513')
#4 /wp-content/plugins/sitepress-multilingual-cms/inc/functions-load-tm.php(947): WPML_TM_Post_Actions->save_post_actions(125514, Object(WP_Post), false)
#5 /wp-includes/class-wp-hook.php(324): wpml_tm_save_post(125514, Object(WP_Post), false)
#6 /wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array)
#7 /wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#8 /wp-content/plugins/sitepress-multilingual-cms/inc/post-translation/wpml-post-translation.class.php(213): do_action('wpml_tm_save_po...', 125514, Object(WP_Post), false)
#9 /wp-content/plugins/sitepress-multilingual-cms/inc/post-translation/wpml-frontend-post-actions.class.php(61): WPML_Post_Translation->after_save_post('752903', Array, 'fr', NULL)
#10 /wp-includes/class-wp-hook.php(326): WPML_Frontend_Post_Actions->save_post_actions(125514, Object(WP_Post))
#11 /wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#12 /wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#13 /wp-includes/post.php(4828): do_action('save_post', 125514, Object(WP_Post), true)
#14 /wp-includes/post.php(4930): wp_insert_post(Array, false, true)
#15 /wp-content/themes/child/promotions.php(292): wp_update_post(Array)
#16 /wp-content/themes/child/promotions.php(184): Quad_Promotions->end_promotion('125514')
#17 /wp-content/themes/child/promotions.php(37): Quad_Promotions->process_promotions()
#18 /wp-content/themes/child/promotions.php(397): Quad_Promotions->__construct()
#19 /wp-includes/class-wp-hook.php(324): qe_promotion_load('')
#20 /wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#21 /wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#22 /wp-settings.php(695): do_action('init')
#23 /wp-config.php(99): require_once('/home/quadexper...')
#24 /wp-load.php(50): require_once('/home/quadexper...')
#25 /wp-blog-header.php(13): require_once('/home/quadexper...')
#26 /index.php(17): require('/home/quadexper...')
#27 {main}
thrown in /wp-content/plugins/sitepress-multilingual-cms/classes/translation-jobs/class-wpml-element-translation-package.php on line 319
Symptoms:
PHP Fatal error: Uncaught TypeError: array_filter(): Argument #1 ($array) must be of type array, bool given in /wp-content/plugins/sitepress-multilingual-cms/classes/translation-jobs/class-wpml-element-translation-package.php:319. We also found these 3 other posts detailing the same error in the same file and line, but there were no provided solutions (at least nothing publicly posted):
https://wpml.org/forums/topic/error-when-we-want-to-translate-a-post/
https://wpml.org/forums/topic/i-get-error-500-when-saving-page/
https://wpml.org/forums/topic/we-are-using-wpml-together-with-wp-all-import-and-we-get-php-memory-errors/
Questions:
What is causing the PHP Fatal error in the WPML plugin?
How can we resolve the TypeError in the WPML plugin?
Kor
Thanks for your patience.
Here is the link hidden link to our sandbox site. Feel free to install the required theme to replicate the issue.
I've also installed the phpmyadmin plugin for you to import the posts into the database.
Please let me know how it goes.
Roxanne Rollin
We exported the troublesome listing via phpMyAdmin and it's postmeta then ran the importer on your sandbox website and it ran the promo check without any issues.
Is your copy of WPML is any different at all?
Kor
Thank you for responding.
I've installed the most recent WPML plugin version. The only distinction I noticed between both sites is the PHP version. You can compare them here: hidden link and hidden link
Could you attempt using a previous PHP version to see if it resolves the issue?
Roxanne Rollin
Downgrading to PHP 8.1 fixes it, however PHP 8.1 is no longer actively supported, it's security fixes only.
Will this be fixed in the next version? When will PHP 8.2+ be supported?
Roxanne Rollin
We installed the WP-phpMyAdmin plugin (same one that was pre-installed on the last demo environment) but the "Enter local phpMyAdmin" results in a 403 forbidden: hidden link
Can you fix this so we can import the post data of the troublesome post?
Roxanne Rollin
This just times out for me, does it load for you?