deepakD-2
Background of the issue:
I am trying to fix a fatal error in the WPML plugin. The error occurs in the file D:wamp64wwwpracticebuzzmtcthemewp-contentpluginssitepress-multilingual-cmsclassescore-abstract-classesclass-wpml-element-translation.php on line 286. I expected to see a fix by adding this code in your next release: private function maybe_populate_cache( in sitepress-multilingual-cmsclassescore-abstract-classesclass-wpml-element-translation.php to handle the error gracefully if ( ! $element_id || ! is_scalar( $element_id ) ) { return false; } The bug was there because element_id is an array. Invalid $element_id: Array ( [0] => 60715 [1] => 60720 [2] => 60804 [3] => 60811 [4] => 60828 [5] => 60834 [6] => 60850 [7] => 60855 [8] => 60862 [9] => 60866 ). Link to a page where the issue can be seen: lien caché
Symptoms:
PHP Fatal error: Uncaught TypeError: Illegal offset type in isset or empty in D:wamp64wwwpracticebuzzmtcthemewp-contentpluginssitepress-multilingual-cmsclassescore-abstract-classesclass-wpml-element-translation.php:282
thrown in D:wamp64wwwpracticebuzzmtcthemewp-contentpluginssitepress-multilingual-cmsclassescore-abstract-classesclass-wpml-element-translation.php on line 282
[25-Nov-2024 06:48:21 UTC] PHP Fatal error: Uncaught TypeError: Illegal offset type in isset or empty in D:wamp64wwwpracticebuzzmtcthemewp-contentpluginssitepress-multilingual-cmsclassescore-abstract-classesclass-wpml-element-translation.php:296
Stack trace:
#0 D:wamp64wwwpracticebuzzmtcthemewp-contentpluginssitepress-multilingual-cmsclassescore-abstract-classesclass-wpml-element-translation.php(60): WPML_Element_Translation->maybe_populate_cache(Array)
#1 D:wamp64wwwpracticebuzzmtcthemewp-contentpluginssitepress-multilingual-cmsclassesquery-filteringclass-wpml-query-parser.php(477): WPML_Element_Translation->element_id_in(Array, 'es', true)
#2 D:wamp64wwwpracticebuzzmtcthemewp-contentpluginssitepress-multilingual-cmsclassesquery-filteringclass-wpml-query-parser.php(446): WPML_Query_Parser->maybe_adjust_parent(Object(WP_Query), 'wpbr_review', 'es')
#3 D:wamp64wwwpracticebuzzmtcthemewp-contentpluginssitepress-multilingual-cmssitepress.class.php(3442): WPML_Query_Parser->parse_query(Object(WP_Query))
#4 D:wamp64wwwpracticebuzzmtcthemewp-includesclass-wp-hook.php(324): SitePress->parse_query(Object(WP_Query))
#5 D:wamp64wwwpracticebuzzmtcthemewp-includesclass-wp-hook.php(348): WP_Hook->apply_filters('', Array)
#6 D:wamp64wwwpracticebuzzmtcthemewp-includesplugin.php(565): WP_Hook->do_action(Array)
#7 D:wamp64wwwpracticebuzzmtcthemewp-includesclass-wp-query.php(1140): do_action_ref_array('parse_query', Array)
#8 D:wamp64wwwpracticebuzzmtcthemewp-includesclass-wp-query.php(1868): WP_Query->parse_query()
#9 D:wamp64wwwpracticebuzzmtcthemewp-includesclass-wp-query.php(3852): WP_Query->get_posts()
#10 D:wamp64wwwpracticebuzzmtcthemewp-includesclass-wp-query.php(3984): WP_Query->query(Array)
#11 D:wamp64wwwpracticebuzzmtcthemewp-contentthemesmtcthemefunctions.php(1045): WP_Query->__construct(Array)
#12 D:wamp64wwwpracticebuzzmtcthemewp-contentthemesmtcthemetemplatespartialscomponentsmtc-listing-card-v2.php(55): mtc_get_reviews_by_source_id(Array)
#13 D:wamp64wwwpracticebuzzmtcthemewp-includestemplate.php(812): require('D:wamp64wwwp...')
#14 D:wamp64wwwpracticebuzzmtcthemewp-includestemplate.php(745): load_template('D:wamp64wwwp...', false, Array)
#15 D:wamp64wwwpracticebuzzmtcthemewp-includesgeneral-template.php(206): locate_template(Array, true, false, Array)
#16 D:wamp64wwwpracticebuzzmtcthemewp-contentthemesmtcthemeincludesshortcodes.php(660): get_template_part('templates/parti...', '', Array)
#17 D:wamp64wwwpracticebuzzmtcthemewp-includesshortcodes.php(434): mtc_generic_shortcode_listing(Array, '', 'listing1')
#18 [internal function]: do_shortcode_tag(Array)
#19 D:wamp64wwwpracticebuzzmtcthemewp-includesshortcodes.php(273): preg_replace_callback('/[([?)(listin...', 'do_shortcode_ta...', '[listing1]')
#20 D:wamp64wwwpracticebuzzmtcthemewp-contentthemesmtcthemesingle-post.php(68): do_shortcode('[listing1]')
#21 D:wamp64wwwpracticebuzzmtcthemewp-includestemplate-loader.php(106): include('D:wamp64wwwp...')
#22 D:wamp64wwwpracticebuzzmtcthemewp-blog-header.php(19): require_once('D:wamp64wwwp...')
#23 D:wamp64wwwpracticebuzzmtcthemeindex.php(17): require('D:wamp64wwwp...')
#24 {main}
Questions:
How can I fix the fatal error in the WPML plugin?
Is there a workaround for the issue with element_id being an array?