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 24 replies, has 2 voices.

Last updated by Mihai Apetrei 1 year, 8 months ago.

Assisted by: Mihai Apetrei.

Author Posts
April 21, 2023 at 10:41 pm #13520073

Mihai Apetrei
Supporter

Languages: English (English )

Timezone: Europe/Bucharest (GMT+02:00)

Hi there.

In regards to this:
Thanks for sharing this solution, Mihai. I followed the steps you provided but at step 2., it crashes the site: "There has been a critical error on this website. Please could you look again at your code and see if you can produce a working version?".

This solution worked perfectly for me in a clean testing environment.

Can you activate the WordPress debug log in order to find out more about what is actually happening when you receive that error - what is the complete error/errors:
https://wpml.org/documentation/support/debugging-wpml/

This way, we can understand more about what is causing the exact issue.

Also, what happens after the error shows up: can you still go back to wp-admin, can you still access it, or do you need to fully restore the site to the state that it was in before using the code?

Please let me know.

Mihai

April 26, 2023 at 10:36 pm #13545231

Phil Cox

Thanks Mihail,

When the error occurs, it is still possible to go back to wp-admin.

I have enabled debugging and here is the log content:
[26-Apr-2023 22:33:13 UTC] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in /var/www/clients/client1/web167/web/wp-includes/class-wpdb.php on line 2397

Please note I have provided Admin access to the site to Andreas who is looking at file permissions.

Kind regards,
Phil.

April 27, 2023 at 11:42 pm #13553735

Mihai Apetrei
Supporter

Languages: English (English )

Timezone: Europe/Bucharest (GMT+02:00)

Hi Phil and thank you for the update.

That error is very important, good thing that we know about it now.

That issue usually shows up when the server resources limit is reached.

Your database is quite big obviously and the server can't handle that operation.

I recommend that you get in touch with the hosting support and share with them that error so that they can increase the server limits.

The code works fine, only I am testing it on a site where the database is not as big as yours and that's why you are encountering that issue. The server is giving up at some point running that function because it takes too long and consumes a lot of resources.

Mihai

April 28, 2023 at 8:54 pm #13559687

Phil Cox

Thanks so much for identifying the source of this error, Mihai. I'll forward this to hosting but it may take a day or 2 due to the weekend. I also have the option of trying the media library fix on another copy of the website on a different host. Perhaps we should try it there also and see whether the outcome is any different?
Kind regards,
Phil.

April 29, 2023 at 8:25 pm #13561667

Mihai Apetrei
Supporter

Languages: English (English )

Timezone: Europe/Bucharest (GMT+02:00)

Hi Phil.

Sure, you can try it there, too, but please understand that there are probably a LOT of records in the database, so it might still kill the server limits on that other hosting where you have that site (I guess it is a different hosting with higher server limits).

This still might happen due to the number of records in the database and the amount of server resources it consumes.

Mihai

April 29, 2023 at 11:01 pm #13561747

Phil Cox

Hi Mihai,
I was able to run the script without causing a memory error.
Points to note when you share this solution in the future:
1. Add the following lines to wp-config.php:
define( 'WP_MEMORY_LIMIT', '512M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
2. Disable ALL non-essential plugins to free up as much memory as possible.
I was able to run the script. It took approx 2 minutes and reported "Done!" when complete.
I then re-activated all plugins and used Dashboard > WPML > Settings > Troubleshooting > "Remove ghost entries".
This also ran without error.
After all that, I have reviewed the media library, to find there are still 151,213 entries in the database. This is no change from before the above exercise.
Please can you suggest what to do next?
Kind regards,
Phil.

May 1, 2023 at 7:13 pm #13566075

Mihai Apetrei
Supporter

Languages: English (English )

Timezone: Europe/Bucharest (GMT+02:00)

Hi Phil.

Thank you for the updates.

1. First of all, I want to let you know that it is not allowed to have the same issue handled in multiple tickets, these tickets are considered duplicated. Our support policy allows us to have only one ticket per issue.

So, the issue reported here, in this current ticket, can't be handled in this other ticket:
https://wpml.org/forums/topic/wpml-reports-languages-not-writeable/

If the initial issue reported in that ticket was resolved, that ticket can be closed.

2. In regards to the code I shared, this worked out perfectly on our test site so I am not sure why it did not work on your side.

I will need a couple of things from you:

- I need your confirmation that you have created a full website backup for the site where you are encountering this issue

- I will need access to the site (I'm activating the private fields below)

- I will need your written confirmation that you want to keep all the media records but have all the other ones, from the other languages, completely removed - please confirm

- and I will need your approval to have your site duplicated on a testing environment that will be deleted after the issue is resolved

This issue might be escalated further so I will need all of that in order to properly escalate this to the next tier.

I will be waiting for your response.

Thank you.

Mihai

May 3, 2023 at 5:32 pm #13581299

Mihai Apetrei
Supporter

Languages: English (English )

Timezone: Europe/Bucharest (GMT+02:00)

Thank you for the credentials, Phil.

This might take a while until it gets resolved but we are doing our best.

I'm leaving the ticket assigned to myself for now.

Mihai

May 10, 2023 at 11:03 am #13621229

Mihai Apetrei
Supporter

Languages: English (English )

Timezone: Europe/Bucharest (GMT+02:00)

Hi there.

I just wanted to let you know that I did not forget about you or this ticket and this is being handled. 🙂

I will get back to you as soon as I have more updates. We are still running a few tests.

I'm leaving the ticket assigned to myself.

Have a lovely rest of the day!

Mihai

May 12, 2023 at 11:48 am #13636893

Mihai Apetrei
Supporter

Languages: English (English )

Timezone: Europe/Bucharest (GMT+02:00)

Hi there.

I'm back.

So, as we are digging deeper into this matter, it seems that, if you go to the Media page (hidden link) and switch languages from the top, you will see that there are close to zero translated images.

From my understanding, the issue that you were experiencing was that there were image duplicates (which would mean that whenever you would add an image, a duplicate of the image would be added for each of the existing languages that were set up with WPML) but it seems that this is not the case.

That's why the script I shared confirms that the function ran successfully (returning "DONE!"), but in fact the issue is related to something else. It seems that there are A LOT of image duplicates in the main language and this is not something that WPML would create.

I don't know why that took place or how they were added, maybe there was another media plugin active or maybe there were some server issues when someone added these images that caused SOME of them to be duplicated.

As you see in one of my screenshots below, SOME images have a lot of duplicates and there are no different names for the image file, it's the exact same name.

That is not something that our plugin would produce.

If we take "Vickie.png" as an example, you will see that there are 7 duplicates of the same image (8 images in total) while on your site you have a total of 13 languages, so it should have been 13 images if WPML was causing that. And they should all show up each under its own language (by filtering the languages from the admin topbar, like this Arabic Media page: hidden link)

On this Arabic media page, you can see only the media example that I added which is "translated" into each of the existing languages and only as a "version" in the database, not as a real file on the server. This feature can be turned off from WPML > Settings > Media Translation (hidden link) by turning off "When uploading media to the Media library, make it available in all languages".

So, you would need a plugin that would clear up any media duplicates from the main Media library.

This one might do what you wanted:
hidden link.

So, although we found out in the end that the issue is not caused by WPML, I still wanted to get this done and test things so that I find a solution that I can share with you, that will solve the issue for you 🙂

So I tested the plugin I shared in the URL above: "Media Deduper"

I first had to "INDEX" all the media from WordPress backend > Media > Manage Duplicates - it took a while to index all the media as it was a pretty big library (151231 records in total). The sad news is that, in the end, it only found a few duplicates (attaching screenshot).

So the plugin was not able to find files that have the same name.

You might need a custom plugin or even better, a developer, that could write some custom code that will find media containing the exact same name and remove that, because I have a strong guess that most of the media files that are added multiple times have the exact same name.

For example, if we go to "Media" and search for "Vickie", we get all the duplicates:
hidden link

This is the best that I was able to do and I tried to do my best hoping that this plugin will do the job, but it didn't.

There are many topics where people complain about this:
hidden link

So maybe there are other plugins or maybe you can find some custom code online that will do this?

Have a lovely rest of the day!

Mihai

Screenshot 2023-05-12 at 14.43.48.png
Screenshot 2023-05-12 at 13.48.30.png
Screenshot 2023-05-12 at 13.23.01.png