Skip Navigation

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

Problem:
The client had previously installed WPML on a site and then decided not to translate it. They manually deleted WPML plugins and dropped all icl tables from the database, which is not the correct way to uninstall WPML. After a redesign, they noticed that there were four copies of every single image in the media library. Reinstalling WPML did not recreate the database tables, and the site experienced crashes.
Solution:
1. We provided a link to our documentation on how to properly delete content and uninstall WPML: WPML reset documentation.
2. Since the icl tables were already deleted, we mentioned that there's no direct way to remove the duplicate images through WPML.
3. We suggested using a third-party plugin, such as Media Cleaner, to help with removing the unnecessary images.

Please note that this solution might be irrelevant due to being outdated or not applicable to your case. If this is the case, we highly recommend checking the related known issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If you still need assistance, please open a new support ticket. Contact WPML support.

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

Last updated by Sean 1 year, 2 months ago.

Assisted by: Bruno Kos.

Author Posts
February 22, 2024 at 12:31 pm #15333493

Sean

Hello.

We are currently using WPML on one site, no problems there. We also have it installed on another site, but have not started translating yet. Also no problems there either.

A while ago I installed WPML on a 3rd site (www.thetravellingchilli.com), completed the basic setup and maybe translated something, but we then decided that we are not going to translated this site at all. I then proceeded to delete all the WPML plugins, and also to drop all the icl tables in the database myself.

I didn't realise at the time that this was not the correct way to completely uninstall WPML, but the site kept working, and so we left it relatively untouched for a while.

Now recently we are busy with a redesign on hidden link, but still without any translation, and we have noticed that there are now 4 exact copies of every single image. A library that had 1600 images now has nearly 7000.

Manually deleting what we think are extraneous images does not work as I believe this multiple images issue was because we did not remove WPML properly from this site. No matter which image we delete, it completely disappears on the post where it was displayed.

So I thought to re-install WPML in order to properly remove it this time, only the WPML database tables are not being re-created, and the whole site is consequently crashing when trying to perform certain actions.

So yes, I am now well aware how to properly remove WPML, but in order to do that I need to first re-install it, along with the appropriate database tables.

Basically, my 2 questions are how to force a re-create of all WPML database tables? And could it have been WPML that caused this multiple image issue, and how to fix that, if it was WPML that caused it?

Screenshot 2024-02-22 at 13.25.15.jpg
February 23, 2024 at 12:58 pm #15337708

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

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

Hi,

Thank you for contacting WPML support!

We have an article on how to delete the content and uninstall the WPML https://wpml.org/documentation/getting-started-guide/language-setup/deleting-languages-and-plugin-data-by-doing-a-wpml-reset-on-your-site/

I'm afraid that once everything is wiped out (icl tables), there is nothing that can be done to remove these images.

Perhaps you can try with https://wordpress.org/plugins/media-cleaner/

Regards,
Bruno Kos

February 23, 2024 at 1:29 pm #15337958

Sean

There is nothing that can be done to remove what appears to be extra references to the images, without flashing our entire 10 year old library? I don't accept that. Elon Musk is shooting internet satellites into orbit on an almost daily basis, then you should also see the scripts that SiteGround wrote to migrate 3 million websites from cPanel to their own proprietary server software, with next to no downtime.

So how about WPML write a little script to fix the problem it caused?

That you have specific documentation when it comes to de-activating and removing WPML has never been clear. By the time a user realises what has happened, it's now too late, and we have to just sit with what appears to be 4-8 copies of an image? Or, rebuild the entire media library from scratch, and then re-attach all images to hundreds of posts? and possibly lose seo image rankings?

This problem has happened to countless others, and every time WPML support just shrugs and says sorry?

So where does it say that you will now sit with what appears to be multiple copies of all images if you remove WPML the wrong way? If we write new posts and want to attach existing images, which one do we use?

But ok, a licensed copy of WPML is now back on the site in question, along with all database tables, and it can stay, although we are not sure we will translate this site any time soon, if at all. I did this to see if it would fix the image problem. It has not. Are there perhaps settings I can run within WPML to fix this issue?

This is a common problem that has been caused by WPML, without fair warning. I think many people would appreciate a fix, or much more clarity and warnings on the risks if WPML is not removed correctly, and the irreversible damage it WILL cause if instructions are not followed to the letter.

When removing Yoast they say to first just deactivate and delete the plugin, then they list the tables in the database that one has to delete by hand. This doesn't take long. People like me then somehow think all other plugins can be removed this way.

Oh, I tried a few cleaner plugins. They don't work, because it's not actually copies, but instead multiple references created by WPML to the same image, references that the WordPress media library now 'sees' after WPML is gone. No matter which 'copy' is deleted, it disappears completely from the post where it was displayed. I know this, because looking in the actual files I only see 1 copy of each size created by WordPress on image upload.

February 23, 2024 at 1:56 pm #15338080

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

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

I fail to see how this is comparable, if e.g. Siteground deleted something within their migration scripts it would no longer work.

The same thing happened here. We offer this guide https://wpml.org/documentation/getting-started-guide/language-setup/deleting-languages-and-plugin-data-by-doing-a-wpml-reset-on-your-site/#step-1-remove-the-secondary-languages-and-all-existing-translations but if you manually delete things from WPML database tables this process will fail.

It would fail for every plugin that has such uninstallation process - whenever you decide to drop tables from database without backup, you can expect issues and we can't be accountable for it.

There is something you can try though:

-- Step 1: Get post_id values to delete
CREATE TEMPORARY TABLE tmp_post_ids
SELECT post_id
FROM wp_postmeta
WHERE meta_key = 'wpml_media_processed';

-- Step 2: Delete from wp_postmeta
DELETE FROM wp_postmeta
WHERE post_id IN (SELECT post_id FROM tmp_post_ids);

-- Step 3: Delete from wp_posts
DELETE FROM wp_posts
WHERE ID IN (SELECT post_id FROM tmp_post_ids);

-- Step 4: Drop temporary table
DROP TEMPORARY TABLE IF EXISTS tmp_post_ids;

But note that this will wipe up ALL the images from media library, not only duplicates, if these images were added into other media libraries if "Translate existing media in all languages" was triggered manually.

So you can try this at on your risk, with a backup of course and I can't guarantee that it would not leave some (or all) posts/pages with 404 on images.

this.jpg
uninstall.jpg
February 23, 2024 at 3:01 pm #15338388

Sean

Maybe the SiteGround analogy wasn't the best. What I meant to suggest is they wrote what I imagined were some very complicated scripts to migrate a massively wide variety of sites from one very different software platform to another, to save them having to move 3 million websites one by one, and this is including any customisations that the site owners might have implemented in their respective sites and databases. And before that, also using scripts, they moved from various hosting providers to Google Cloud Platform. Of course, they had backups, on both counts. I do too, but not going back far enough. I have not been into this site's media library since I removed WPML. Had I done so, I would have noticed sooner and could have rolled back and done it properly, unless it was a bug with the version of WPML in use at the time.

So again, what I am asking is if the coders of WPML, who wrote what seems to be the most complicated and advanced translation plugin in the universe could come up with something quick to fix this problem, which is actually kind of small, but still highly annoying. And unless you can prove I was duly warned and deliberately ignored it, I think it's only fair for you (WPML) to help in some way. I and everyone else pay you good money, every year. I'm sure you'd like to keep your customers.

No, I didn't delete anything from within the tables, I just dropped the complete list of icl tables after I deleted the 4 WPML plugins. That's it. I believe that is what the plugin itself does anyway. But in my case nothing had been translated, so I didn't think there was any need to delete anything else, as there wasn't anything else to delete.

But in my case now I haven't actually lost anything. I still have all the images, and they are showing once in the posts as always, it's just when you go into the media library there appear to now be 4 copies of each one. This makes managing the library a royal pain. It's also creating havoc when I try create webp images. The webp plugin tries to create webp copies of nearly 6000 images, and not the 1200 we actually have.

So I'll ask one more time, is there no way to simply collate these extra database records created by WPML to tell the WordPress media library there is in fact only one copy of each image?

This guy came up with a script, and it worked in that case, but it doesn't seem to work in my case, nothing at all happens when I run it:

https://wpml.org/forums/topic/stopped-using-wpml-now-the-media-library-has-duplicate-images/

February 24, 2024 at 7:08 am #15339976

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

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

When you disable (or even delete) WPML plugins, all icl_ tables still remain there. This works for most other plugins, rarely plugins will remove all the data upon their removal or deactivation, especially more complex ones. That being said, with WPML all the language information and settings are preserved so you can come back later.

The only option that does what you did is our "Reset and deactivate WPML" button which is only available through troubleshooting and warns you what would happen.

And unless you can prove I was duly warned and deliberately ignored it

It is not up to WPML to warn clients, nor I am aware that other plugin and theme developers warn their client on not to delete database tables directly, this is more of a common WordPress (and not only WordPress) knowledge.

The script would not work because there is no language information available (also as Nigel mentioned: "it is important you do so while the WPML tables are still intact, so that the duplicated content can be identified."), also it was suggested before we implemented advanced removal features of all the translated and duplicated content (and this includes media library items as well), in fact at the request of our clients who needed this.

reset.jpg
February 24, 2024 at 7:11 am #15339991

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

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

You can try my script though but may not work as expected - therefore try it on the staging site to see what happens. It may work because I suppose you probably had automatic duplication of images and didn't trigger this manually.

February 24, 2024 at 10:10 am #15340151

Sean

What I find interesting is even though WPML is fully back, with all tables, the lot, the media library is still an absolute mess. This was after I re-installed and properly removed it before putting it back again.

So now WPML is there, set up and ready to go with all settings default, but with little intention to ever translate this site, only I still have little to no idea what to do about the media library, other than to now throw some money at the situation. I am spending too much time on this now. We are stuck and can't further develop this site in this condition. It doesn't matter anymore what caused this, it just needs to be fixed.

Fact: I'm looking at 4 'copies' of all images in the WP media library. They just need to become one. How hard can it be to write a script to collate these references to the same image? Sure, such a script probably doesn't exist yet as no one has ever done something like this before, ever....

No, the script in that other case doesn't work in mine, but it did in his.

Then there is this guy who wasn't happy, and neither am I, not at all. No resolution that I can see was found, after weeks of back and forth, in that case:

https://wpml.org/forums/topic/duplicate-images-after-deactiviating-wpml/

So yes, this has happened, many many times before. What is being done to ensure this doesn't keep happening? or do you want to keep fielding tickets like these?

Oh, and telling a paying customer he is wrong is very bad business practice. I'll take that into consideration if someone asks me to recommend a translation plugin.

February 24, 2024 at 1:36 pm #15340440

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

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

Nowhere did I state that something was done wrongly by you, I just state the mere fact that deleting database tables directly without making a backup can bring consequences we can't be accountable for.

In any case let me bring our support management here (about further decisions) because at this point, I have nothing further to add neither I have means to help with this.

February 26, 2024 at 3:51 pm #15345206

Sean

After about 2 weeks of solid research, and finally hiring someone to look into it, I think I have finally realised what happened. Unfortunately though, said pro could not offer a guaranteed fix, except for a very detailed report, which included thousands of orphaned database entries.

But yes, you might actually be right when you say there is no script that can fix something like this, no single script, and even then, the final consensus is that our only real option now is to re-build the entire library from scratch. In our case this isn't a huge problem as we still have all images locally saved, and there are only about 800. We just have to now go into each post one by one and re-upload/attach. We are looking at several days for the 2 of us to do this. We are just slightly concerned about losing rankings for all the images as the engines might see them as new.

The other option is to just leave it in this state, but as we are now actively working on this site again having 4 copies of everything gets in the way. Which copy do we add to posts?

I'm now 99% certain my manually dropping the icl_tables the first time did not cause this problem. The same tables the plugin itself drops anyway.

It would seem the WPML removal instructions are missing 1 very important step:

Step 1: Remove the secondary language(s) and all existing translations. Fine....

But what it would seem should be done next is all the images from the other languages also need to be deleted, even if not translated. Depending on the exact settings, WPML usually duplicates the references to every image, ready for translation. In other words, if you have an existing site and then later add WPML, you can force a duplicate of existing images. You can then set it to automatically duplicate any subsequent media uploads, to be later translated. It could be that you don't intend translating everything, so you might not want WPML to duplicate everything. What are those default settings?

You say to only remove 'all existing translations', so one does not realise they must also go into the media library, switch to any other languages, and delete whatever is in there, even if not translated. Only then should you move onto the next step.

I thought because I had not translated anything on this site, there was nothing else for me to delete, so I neglected to look in the media library and proceeded to delete the .mo .po files, then reset/deactivate the plugin.

Now I have 4 'copies' of all images because I actually first installed WPML in 2021, then again last year. But WPML is now gone again as we are not planning on translating this particular site. I must also admit that this site has been a bit neglected for a few years now, so I didn't notice the media library until it was way too late.

Each time after removal, the WPML duplicated images now appeared in one library, and when WPML was re-installed the 2nd time it saw those 2 copies as 2 images, and now we have 4.

As mentioned, the other problem in this case is by the time I noticed the library issue the backups from before WPML was removed were now gone. If WPML removal instructions were clearer, I would have noticed this issue, or not even have had it in the first place.

In fact I think there are 2 other steps you could include. Step 1: First make a full site backup before attempting WPML removal, because if done wrong, problems will happen. If problems occur, simply roll back and try again.

And the last step; check your site after WPML removal and verify all is on order, before you do any further development.

I have been working with WordPress a solid 10 years now and have built and launched quite a few sites, and I somehow missed something like this? I have done a lot of manual database dropping, with zero issues, on this site and others. Yes, I know it is risky, but this?

"It is not up to WPML to warn clients, nor I am aware that other plugin and theme developers warn their client on not to delete database tables directly, this is more of a common WordPress (and not only WordPress) knowledge."

It actually is, if you want to make your product more accessible to beginners. And no, such knowledge is not that common as you might think, especially considering how 'easy' it is to start with WordPress these days. Yes, there are warnings out there, just not always that clear, even to someone like me who's been doing this a while.

Sometimes a little white glove help is required. Not everyone thinks like a developer. 10 years on and I still have so much to learn about all this, and I'm at it pretty much every day.

So imagine how WPML looks to someone just starting out after they just Googled 'best translating plugin'. WPML usually comes up top, but with no obvious warnings that it is not for beginner website builders. Fact; it is not. With that said, it is a very powerful plugin, and we will be sticking with it, but maybe only because switching would be more work than learning how to just keep using it 😉 I think it has got to be the most advanced set of plugins I have ever worked with.

I know, I need a much better backup strategy, and I've been doing this for a while. How much of a backup strategy does an absolute beginner have?

In the latest screenshot; perhaps you can include a link to 'Plugin removal instructions. Must be followed exactly'. This is assuming they are not missing any steps. Only then can you be absolved of all responsibility, if something goes wrong.

Ok, I think that's enough. In the meantime I have learned a whole lot. Now we have a little library to re-build, with only 800 entries, and we weren't even hacked. The British Library have a catalogue of millions of entries to re-build....

Thank you for your time.

Screenshot 2024-02-26 at 16.11.13.jpg
February 26, 2024 at 5:16 pm #15345596

Sean

I could still be wrong, about some of this. At the end of the day the only fix for this situation is a complete re-build of the media library. I just wish I'd been told that sooner. Exactly what caused this is still unclear. What is clear to me though is WPML was involved.

February 27, 2024 at 8:19 am #15347554

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

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

There is something you can try:
https://wpml.org/forums/topic/duplicate-images/#post-11439915

But use this query instead:

DELETE FROM `wp_posts` WHERE `post_name` REGEXP '^.+-[1-9]{1}$' AND `post_type` = 'attachment';

Perhaps it can help, at least a bit, but try this in staging website.

February 27, 2024 at 10:31 am #15348461

Sean

Siteground now have an in-house premium support service, for non-hosting related issues. It was them who I finally contacted. A few of their senior service reps who already have unfettered root access to all SG hosted sites got involved in this case. They tried all sorts of CLI commands and SQL queries, and even they couldn't guarantee a fix, which is what I'm looking for.

So, I have decided the only way to properly fix this media library is from scratch. The end product will then be guaranteed. It's just going to take a bit more time, but still less time than trying to fix this any other way. This site might now actually pass Core Web Vitals after this re-build.

I first emptied the media library database with one query, then deleted all the image files from the Uploads folder. Yes, we are doing this all in staging with the live as a reference as to what should be in each post.

Admittedly, this is the first site we ever built where we made a lot of rookie mistakes; images with the same title/file name as pages and posts, 2MB images, many without alt text, using cheap, sub-par hosts and poorly coded compression plugins that timed out and crashed the site after having done weird things to existing images, etc etc etc.

So, it would seem this has been a long time coming, a culmination of events that ultimately lead to a corrupted media library, and unfortunately WPML was somehow involved, hence this ticket.

I do appreciate the offer of help. But if I may be so bold, telling a customer they are now asking for help outside the scope of your support and that they need to find help elsewhere actually isn't a bad thing. It may well save us all some time. Siteground are pretty clear about that, hence their new premium support service. And even then, things still get broken beyond repair, where being helped to realise this sooner rather than later is a good thing.

We sent our car in for general service recently. There was also something wrong with the brakes. They tried fixing them with some computer adjustments, but soon told us we need a new ABS pump and front discs and pads. So we said just do that, despite the price. The alternative was to keep fiddling, or to keep driving around with bad brakes which might then lock up on the Autobahn at 160Kph.

In the case of the site in question, it is just going to cost us some more time, but the end is now in sight, after some good lessons learnt.

I have a few live hobby sites I often use for testing. I installed and removed a licensed copy of WPML, a few times. I cannot re-create this problem. So, I'm just going to chalk this up to yet another glitch in The Matrix.

All is now good.