BTW: I added helper function to /wp-content/plugins/sitepress-multilingual-cms/classes/core-abstract-classes/class-wpml-element-translation.php and than used it where necessary (in maybe_populate_cache() and get_element_lang_code(), which solved the error.
The function:
/**
* Ensures an element ID is in the correct scalar format
*
* @param mixed $element_id The element ID to normalize
* @return int|null Normalized element ID or null if invalid
*/
private function normalize_element_id($element_id)
{
// Handle case when a post object is passed instead of just the ID
if (is_object($element_id) && isset($element_id->ID)) {
return intval($element_id->ID);
} elseif (is_array($element_id) && isset($element_id['ID'])) {
return intval($element_id['ID']);
} elseif (is_scalar($element_id)) {
return intval($element_id);
}
return null; // Return null for invalid values
}
Symptoms:
The maybe_populate_cache() function is receiving the entire WP Post object instead of just the post ID.
Questions:
What could be causing the maybe_populate_cache() function to receive the entire WP Post object?
Can you help me look for the cause on our end in the right direction?