Skip Navigation

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 topic contains 28 replies, has 3 voices.

Last updated by Sumit 1 year, 9 months ago.

Assisted by: Sumit.

Author Posts
January 18, 2023 at 6:16 pm #12845667

Faisal Ahammad

Hi there,
Good afternoon. Our 2nd tier support team discovered numerous attachments that were missing language information from the icl_translations table. As a result, WPML attempted to translate the attachment but received empty records, leading to the error. Generally, WPML sets the attachment language as soon as WPML is activated or the attachment is uploaded, but we are unsure why these records are missing in this case.

To resolve this issue, please follow these steps:

1. Navigate to WPML > Support > Troubleshooting
2. Run Remove ghost entries from the translation tables, then Set language information. Please note that this process may take a few minutes, so max_execution_time should be set to at least 10 minutes. You can set set_time_limit(0); in wp-config.php and remove it after running the troubleshooting options.
3. Once the process is complete, update the page. This should resolve the issue.

I hope this helps. Please let me know how it goes.

Thank you,
Faisal

January 19, 2023 at 7:54 am #12848215

kristoferS-2

I ran the "Remove ghost entries..." function from the troubleshooting page and got the "Done!" confirmation. Now the sql errors in the error_log file does not appear but updating the page still times out. Same in the cloudways clone.

January 19, 2023 at 9:27 am #12848627

Faisal Ahammad

Hi,
Good morning! I have forwarded the update to the second-tier support team and will update you as soon as I receive a response.

Thank you for your patience.

January 24, 2023 at 2:11 pm #12882649

Faisal Ahammad

Hi,
Good morning. We have investigated and tested the reported issue of updating a post on your website and have identified that the issue is caused by a large number of media files (around 250,000) being duplicated by WPML, resulting in a timeout error. We have confirmed that this issue can be resolved by setting the media post type to "Do not translate" and successfully updating the post.

Additionally, we have noted that you have set your website to translate the media files into English in WPML settings; however, this process may take a couple of hours due to the large number of files.

As a solution, we recommend duplicating the media files, which will allow for translation of media description, caption, and alt text. Please be aware that this process may also take a significant amount of time. Check the following link for more details: https://wpml.org/documentation/getting-started-guide/media-translation/#id5

If you have any further questions or concerns, please do not hesitate to contact us.

Thank you
Faisal

January 25, 2023 at 12:04 pm #12889651

kristoferS-2

That is very strange. I just started media duplication from Media Translation settings and it is counting around 90 000 items. However, from the Media section of the dashboard I only have about 1 000 items.

How is it possible that WPML is counting that many more media items than my media library?

January 25, 2023 at 3:32 pm #12891753

Sumit
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi,

I am Sumit from 2nd tier support.

As I can see the total media files in your database is 250 thousand approx. Please see the attached screenshot.
You are seeing fewer media file in the media library because the language for those media files are missing from WPML tables and WPML skips those records when viewing the media library.

This is expected when media files missing the language records (i.e. no language attached) are not displayed in the media library. If you disable WPML you will see the same number of results in the media library as in the database.

I checked the few media entries closely and it seems those are corrupted may be due to some plugins/theme or database operations.

If you don't want to use those media files please consider using this plugin https://wordpress.org/plugins/media-cleaner/ and remove the records. Before that please make sure

#1 You have a full backup of site files and database.
#2 Turn on "When deleting a post, delete translations as well" and "When deleting a taxonomy (category, tag or custom), delete translations as well" in WPML > Settings you that when you are deleting the media files the translated media should be deleted if exist.
#3 Turn these options off after media cleanup. As those are global options and affect the whole site not just media files.

Afte cleaning up media files you can try duplication in WPML media.

I hope it will help to fix this issue.

Thanks

Screenshot 2023-01-25 204434.png
January 27, 2023 at 8:19 am #12902179

kristoferS-2

Thanks for the information. I am in the process of running Media Cleaner and it is taking very long time indeed. It may be a few days before the next update so please keep the case open.

I could of course have deleted the non functioning page and recreated it but I thought could be a good idea to find the root cause of the timeout. In this case the page had a broken attachment reference that was duplicated over 100 000 times.

Really appreciate the thorough investigation.

January 27, 2023 at 7:48 pm #12906509

Sumit
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi,

Thanks for the feedback.

In this case the page had a broken attachment reference that was duplicated over 100 000 times.

Do you mean the page was having a broken attachment and then created duplicated entries in the database because of WPML?
Could you please help us by sharing screenshots and duplicated attachment URLs?

Of course, if the problem is caused by WPML we will try to replicate it on a fresh site and report it to the devs.

And I really thank you for the help in this troubleshooting.

Thanks

January 30, 2023 at 8:56 am #12919341

kristoferS-2

I have already deleted these attachments from my site. But in the clone that you setup for me you should be able to find a large number of attachments in the wp_posts table that contains AdobeStock in the guid.

I gave up on Media Cleaner because it was so slow and kept stopping after running it for days with little progress. I reviewed the source code for the delete function Media Cleaner, which led me to wp_delete_attachment in core. Judging from that what I needed to do was:

1. Delete the corrupt Media posts

DELETE FROM wp_posts
WHERE post_type = 'attachment' AND guid = 'GUID YOU WANT TO DELETE HERE'

2. Delete any remaining orphaned metadata (thanks hidden link)

DELETE pm
FROM wp_postmeta pm
LEFT JOIN wp_posts wp ON wp.ID = pm.post_id
WHERE wp.ID IS NULL

In this case the file did no longer exist in my uploads folder so I did not have to do anything about that.

I am not sure if WPML truly was the culprit here, but disabling WPML was what led to the discovery of all these duplicated attachments. After deleting these they do not seem to be recreated upon updating the page that was timing out.

January 30, 2023 at 1:44 pm #12922179

Sumit
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi,

Thank you very much for the details.

I will look into the issue as soon as I can. For now, the issue on your site has been fixed right?
I will keep you posted.

Thanks

January 30, 2023 at 2:06 pm #12922341

kristoferS-2

Yes the issue in my site is resolved.

I understand you can investigate the corrupted database in your clone in case you want to investigate it further.

February 1, 2023 at 7:03 am #12934843

Sumit
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi,

Just to update you I have investigated the issue and those thousands of records are created by WPML but the issue was not due to any logical error in WPML but due to a corrupted database.

Let me explain what happened.

When you update the post in English or update the translation, WPML tries to translate the image but after inserting the attachment entry WPML fails on setting the language and thus it keeps increasing the post table.
There is an image in the post with ID 7727 and it is a translation (SV) of English image ID 7726 (original). (See the screenshot) The attachment with ID 7726 does not exist in the wp_posts table. When you update the translation WPML does not find any attachment entry in the posts table so it creates a new entry for the posts table but when WPML tries to set the language information the entry exists in the icl_translations table thus it fails.
Due to this, the new record in the posts table has no language and this process keeps repeating on each translation update.

Solution:-
Simply running remove ghost entries in WPML > Support > Troubleshooting fixes the problem. Also, it is not possible to delete the attachment from the dashboard without removing icl_translation records. It is only possible when you use a script or delete it directly from the database.

I think not just WPML but any software can behave unexpectedly due to a corrupted database but our troubleshooting options are designed to fix most of the corruption issues. So you can always run them after taking a database backup if you see any issue related to database corruption.

Thanks

Screenshot 2023-02-01 123110.png
February 1, 2023 at 7:21 am #12934919

kristoferS-2

Thank you for the update. I truly appreciate the effort you put into this.

February 2, 2023 at 3:21 pm #12949023

Sumit
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Thank you! Since you confirmed the issue is fixed I am closing this. 🙂