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.

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

Problem:PHP Fatal error: Uncaught TypeError: Argument 1 passed to WPML_Media_Post_Images_Translation::translate_images_in_post_content() must be an instance of WP_Post, null given, called in /home/site/www/site/v2/wp-content/plugins/wpml-media-translation/classes/media-translation/class-wpml-media-post-images-translation.php on line 107

Solution:1. Go to WPML > Support > Troubleshooting 2. Click on the button "Remove ghost entries from the translation tables".

Relevant Documentation:

This topic contains 9 replies, has 2 voices.

Last updated by retoT 1 month, 4 weeks ago.

Assigned support staff: Bobby.

Author Posts
August 13, 2019 at 1:08 pm

retoT

Hi,

There is a problem, whenever I try to do some major change, like changing an item in the main menu (Hauptmenü-testing), I get a technical problem message and the change would not be saved (see attachment). To get such a change saved, I will need to deactivate all WMPL plugins, save, and reactivate. That is not acceptable. I consulted our programmer and he said they had a similar issue with another website using WPML. Please let me know how to solve this.

Thanks,

Reto

August 13, 2019 at 7:48 pm #4390473

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hello,

I would need to see the detail of the error to get a better idea of what might be causing this . You can see how to enable debug logging here:
https://wpml.org/documentation/support/debugging-wpml/

Go in your wp-config.php file and look for define(‘WP_DEBUG’, false);. Change it to:
define('WP_DEBUG', true);

Edit your wp-config.php file and add these lines, just before it says 'stop editing here':

ini_set('log_errors',TRUE);
ini_set('error_reporting', E_ALL);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');

This will create an error_log.txt file in your site's root directory. Please send me its contents.

also please increase your WP_MEMORY_LIMIT to 256M or higher

August 14, 2019 at 9:46 am #4393779

retoT

Here you go:

[14-Aug-2019 09:44:28 UTC] PHP Fatal error: Uncaught TypeError: Argument 1 passed to WPML_Media_Post_Images_Translation::translate_images_in_post_content() must be an instance of WP_Post, null given, called in /home/swissgrc/www/swissgrc.myhostpoint.ch/v2/wp-content/plugins/wpml-media-translation/classes/media-translation/class-wpml-media-post-images-translation.php on line 107 and defined in /home/swissgrc/www/swissgrc.myhostpoint.ch/v2/wp-content/plugins/wpml-media-translation/classes/media-translation/class-wpml-media-post-images-translation.php:130
Stack trace:
#0 /home/swissgrc/www/swissgrc.myhostpoint.ch/v2/wp-content/plugins/wpml-media-translation/classes/media-translation/class-wpml-media-post-images-translation.php(107): WPML_Media_Post_Images_Translation->translate_images_in_post_content(NULL, Object(WPML_Post_Element))
#1 /home/swissgrc/www/swissgrc.myhostpoint.ch/v2/wp-includes/class-wp-hook.php(288): WPML_Media_Post_Images_Translation->translate_images(905)
#2 /home/swissgrc/www/swissgrc.myhostpoint.ch/v2/wp-includes/class-wp-hook.php(310) in /home/swissgrc/www/swissgrc.myhostpoint.ch/v2/wp-content/plugins/wpml-media-translation/classes/media-translation/class-wpml-media-post-images-translation.php on line 130

August 14, 2019 at 9:49 am #4393857

retoT

By the way, I had changed memory limit on the server to 256 MB already prior to contacting you. I have now also added this line to wp-configj:

define( 'WP_MEMORY_LIMIT', '256M' );

but it still shows:

Speicherlimit 40M Ein Speicherlimit von mindestens 128MB wird benötigt.

Why is that?

August 14, 2019 at 5:52 pm #4396967

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Thank you for the error log

This is an error i have seen before and it usually relates to a corrupted database entry for the menus

how many menus do you currently have at the moment . ? if possible please share a screenshot of your menus page with me

also as a first test I recommend to perform a cleanup of WPML translations with the following steps:

1. Go to WPML > Support > Troubleshooting
2. Click on the button "Remove ghost entries from the translation tables".

let me know your results please

August 15, 2019 at 7:28 am #4399275

retoT

Hi Bobby,

Don't know why I'd have to send you screenshots even though you have login information?

Anyway I performed the "Remove ghost entries" task and menu can now be saved again without deactivating WPML plugins.

But you're right: There are many menus and I left them as I am not sure which ones are in use (I did not create the website). As it is working again now: Do I still need to get rid of any unused menus or is it OK if I leave them? The latter would obviously be preferred but if needed I'll investigate and delete menus.

Also please let me know about my question as for memory limit: Why does your overview page show 40M of memory limit even though I increased it to 256M in wp-config?

Thanks and have a fantastic day!

Reto

August 15, 2019 at 5:35 pm #4402743

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hi Reto,

i am glad to hear that the issue has been resolved.

If you are not experiencing the error anymore i dont believe there is a need to delete your menus

Regarding the memory limit within WPML->Support page

there are 2 concepts, the maximum memory that PHP allows (in php.ini) and

the maximum memory that WP will use (ie: 40mb by default in the frontend for single sites)

so the first value will be taken from what i set in your php.ini and the second value is taken from what is set in your wp-config.php file

August 16, 2019 at 11:57 am #4406169

retoT

Hey Bobby,

I know that and as I said I did change memory limit in wp-config and it would still show 40M in your backend.

Thanks for your assistance and have a great day, Bobby!

Reto

August 16, 2019 at 8:13 pm #4408061

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

There is a possibility its not being picked up within our support page

i have test this on my environment and its working as expected

being that this serves as a debugging tool for us i believe it should be ok as long as your php.ini set WP MEMORY LIMIT is set to 256M or higher from the server side

August 18, 2019 at 7:07 pm #4412655

retoT

Excellent, thank you!