Skip Navigation

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

Problem:
The client experienced an issue where 40,000+ duplicate images were created due to a hiccup, and after removing unused media, including media from translations, all media on translated pages went missing. The client is looking for a way to 'recycle' or 'retranslate' the media so that it works on the translated pages as it does on the non-translated pages.
Solution:
We recommend the following steps to address the issue:
1. If you have a backup from before these database changes were made, utilize it to restore the missing entries.
2. If no backup is available, follow these steps:

1. Create a full website backup.<br />2. Complete all translations marked as "update needed" in the Translation Editor by clicking "Complete." This will restore the missing images.<br />3. For pages/products created in secondary languages, manually restore the images in the page editor.

We always advise having a backup before making any changes to prevent such issues.

If this solution does not resolve your issue or seems outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If further assistance is needed, please open a new support ticket at WPML support forum.

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.

Tagged: ,

This topic contains 25 replies, has 4 voices.

Last updated by Lucas Vidal de Andrade 2 months, 2 weeks ago.

Assisted by: Lucas Vidal de Andrade.

Author Posts
July 3, 2024 at 10:20 pm #15887118

Andreas W.
Supporter

Languages: English (English ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

This is Andreas from the Second Tier Support Team.

I have synced your media files today at:
WPML > Settings > Media Translation > Start.

The count of media files is not identical inside the media library when changing the language inside the top admin bar. Please do not remove those media entries. They are mandatory for displaying media in other languages.

The problem that your site was experiencing was a long known issue that occurred longer time ago (media entries get duplicated once a new language is added). This issues is not yet solved and the data cleanup has to be taken manually:

https://wpml.org/errata/all-media-is-duplicated-when-a-new-language-is-added/

I would kindly like to encourage you to reach out to us first in case a similar issue occurs and ask for our support before taking direct action on the database.

I was able to confirm that on products that are currently missing images it is sufficient to simply save the product on the WordPress Editor. You also could use the WooCommerce Bulk Edit option for this purpose but for some reason, your site is showing host errors once I am trying to edit more than 20 products at the same time. I am not sure what is causing those errors but it seems to be a server limitation.

You can use a custom snippet to save all existing posts, pages, and products.

Add this snippet to the end of the functions.php file of your theme:

// Add a function to the admin_init hook
add_action( 'admin_init', 'save_all_posts_on_refresh' );
 
// Define the function to save all posts on refresh
function save_all_posts_on_refresh() {
  // Check if the current page is the posts page
  global $pagenow;
  if ( $pagenow == 'edit.php' ) {
    // Get all the posts
    $args = array(
      'post_type' => array('page', 'post', 'product'),
      'numberposts' => -1
    );
    $all_posts = get_posts( $args );
    // Loop through all the posts and update them
    foreach ( $all_posts as $single_post ) {
      wp_update_post( $single_post );
    }
  }
}

Now, go to Posts > All posts. Finally, remove the snippet from the functions.php file. This should have saved all posts, pages, and products and recreated the missing image translations.

Let me know if you need my assistance with this task, but I recommend that you provide us FTP access first for this purpose. The private reply form is enabled again.

Also, take note that you can only automatically translate content that was created in site's default language. For example, some of your products might currently not show images, as you did not create the original products in the site's default language and those original images have been removed from the server. You will need to upload the images again to the original products.

You can see more details about this at WooCommerce > WooCommerce Multilingual & Multi-Currency. See the screenshot of the original products' missing images. If you take a close look you will realize that there are many products that were not created in the site's default language and as you removed the images in this language from the database you actually did not remove translation, you instead removed the original images.

Apart from that I also can see products created in site default languages that are missing images. The translations can only work as expected if the original contents do have the images.

Please review your site and revise if we can spot further issues in regard to the translations that need our attention and we will be glad to assist you on this matter.

We would appreciate it if you could provide exact examples in this case.

Best regards
Andreas

example products.jpg
July 5, 2024 at 8:26 pm #15900155

tannerT

Your provided function crashed my server & created 14 pages, of pages, with (no title). Yes, I implemented correctly (we are a corporate level dev team). I rewrote your script to include batch processing, logging, percentage tracking, propert updating, and designation to a custom url vs. running for any admin who might hit this page. A full list of improvements can be found below:

- Custom URL Trigger: Custom URL [/save-posts/] to trigger script.
- Batch Processing: Declarative to change batchcount
- Progress Tracking: _last_processed meta key & last_processed_post_id meta keys
- Logging: Detailed Logging [wp-content/save_posts_log.txt] Each log entry includes the post type, ID, title, and percentage complete.
- Percentage: Calculated percentage complete on current post ID and maximum post ID.
- Completion: CONGRATULATIONS: All posts/products/pages on completion

That code can be found here:

// Register custom URL endpoint
add_action('init', 'custom_endpoint');
function custom_endpoint() {
add_rewrite_rule('^save-posts/?$', 'index.php?save_posts=1', 'top');
add_rewrite_tag('%save_posts%', '([^&]+)');
}

// Add query variable to catch the custom URL
add_filter('query_vars', 'custom_query_vars');
function custom_query_vars($vars) {
$vars[] = 'save_posts';
return $vars;
}

// Hook the function to template_redirect
add_action('template_redirect', 'save_posts_on_custom_url');
function save_posts_on_custom_url() {
global $wp_query;

// Check if custom URL is accessed
if (isset($wp_query->query_vars['save_posts']) && $wp_query->query_vars['save_posts'] == 1) {
save_all_posts_on_custom_trigger();
exit;
}
}

// Function to save posts
function save_all_posts_on_custom_trigger() {
global $wpdb;

// Get the last processed post ID from options table
$last_processed_id = get_option('last_processed_post_id', 0);

// Get the maximum post ID to calculate percentage complete
$max_post_id = $wpdb->get_var("SELECT MAX(ID) FROM $wpdb->posts WHERE post_type IN ('page', 'post', 'product')");

// Get the next set of posts to process
$args = array(
'post_type' => array('page', 'post', 'product'), // Process pages, posts, and products
'posts_per_page' => 300, // Limit to 300 posts per refresh
'orderby' => 'ID',
'order' => 'ASC',
'post_status' => 'any',
'post__not_in' => array($last_processed_id),
'meta_query' => array(
array(
'key' => '_last_processed',
'compare' => 'NOT EXISTS'
)
)
);
$all_posts = get_posts($args);

// Open the log file in append mode
$log_file = fopen(WP_CONTENT_DIR . 'https://cdn.wpml.org/save_posts_log.txt', 'a');
if (!$log_file) {
echo 'Could not open log file.';
return;
}

// Check if there are posts to update
if (!empty($all_posts)) {
foreach ($all_posts as $single_post) {
wp_update_post($single_post);
update_post_meta($single_post->ID, '_last_processed', time()); // Mark the post as processed
update_option('last_processed_post_id', $single_post->ID); // Save the last processed post ID

// Determine the type of post
$post_type = ucfirst(get_post_type($single_post));

// Calculate the percentage complete
$percentage_complete = ($single_post->ID / $max_post_id) * 100;
fwrite($log_file, "{$post_type} ID: {$single_post->ID} - Title: {$single_post->post_title} - Percentage Complete: " . round($percentage_complete, 2) . "%" . PHP_EOL);
}
fwrite($log_file, 'Processed ' . count($all_posts) . ' items.' . PHP_EOL);
echo 'Processed ' . count($all_posts) . ' items.';
} else {
// If no posts are found, reset the last processed post ID and log the completion message
delete_option('last_processed_post_id');
fwrite($log_file, 'No posts found for updating or all posts have been processed.' . PHP_EOL);
fwrite($log_file, 'CONGRATULATIONS: All posts/products/pages have been updated.' . PHP_EOL);
echo 'CONGRATULATIONS: All posts/products/pages have been updated.';
}

// Close the log file
fclose($log_file);
exit;
}

ACTION LOG:
1.) I ran the updated version (as it is the only script that works correctly) until completion.

The complete log can be found here (note logging implementations changed up top until I decided percentage based was the best manner): hidden link.

Completion is identified by this message when accessing [/save-posts]: CONGRATULATIONS: All posts/products/pages have been updated.

2.) I ran some tests by:

a.) Changing Admin Panel Default Language to es-us while inside of the edit admin of several products (I cannot change language on the frontend because of the another issue being experienced in an additional ticket that is getting nowhere if you want to take a look at that. It is my only other issue):

hidden link
hidden link
hidden link

So the links changed to:

hidden link
hidden link
hidden link

I then opened those pages in a new window: I GET 404 PAGE NOT FOUND FOR THESE PRODUCTS. SO LIKELY RELATIVE TO THE OTHER TICKET.

b.) Testing a different manner. I started by accessing es.ellasbubbles.com. I tested the products and pages that do seem to not be affected by the issue in another ticket:

- All of the links in the footer take me outside of es.ellasbubbles.com (so can't test this either. not sure if this is relative to the other ticket, dropping a comment there as well). What a mess

- Most pages seem to have "some" restored, with exception to a few [Note their page ID's are listed in the update log]:

hidden link
hidden link
hidden link
hidden link
hidden link

Please do conduct a thorough evaluation on your end. Awaiting your comments, resolutions, and if FTP is needed enable the secure form

July 5, 2024 at 8:34 pm #15900165

tannerT

Please note that the images on my United States English Products: hidden link

Are showing in Spanish

This is CRITICAL to SEO, and must resolved immediately.

Let me know what your team needs to implement permanent solutions; and feel free to escalate this as high as required. Clearly, we are suffering from WPML issues for over a year that have never been addressed properly and are now placing adamant attention pressing for an affirmative resolution

July 10, 2024 at 1:30 pm #15928261

Lucas Vidal de Andrade
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hey there,

I want to give you feedback, that we're analyzing your issue internally, as you may already know. I know this is taking time, but it's an usual situation that needs a greater attention from us.

I'm speaking directly to Andreas about the code you sent and the specifics of the issue you're facing. We'll give you feedback as soon as we can. I appreciate your patience and cooperation.

July 10, 2024 at 5:31 pm #15929488

Lucas Vidal de Andrade
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello,
Thank you for sharing the revised code. We apologize for any unexpected behavior it caused on your website, and we’re glad you found a solution that works for you. The snippet was intended to provide a temporary workaround.

I reviewed the examples you sent. Some of them had an “update needed” status. In those cases, updating the translations resolved the issue. I did this for the following page: hidden link.
For other examples, like this one: hidden link, the entries were created in secondary languages, and the original media entry was manually deleted. These need to be restored via the page editor (please refer to the attached screenshot for reference).

To resolve these issues, please follow these steps:
1. Create a full website backup.
2. Complete all translations marked as “update needed.” You can do this by accessing the Translation Editor and clicking on “Complete.” This will restore the missing images.

For pages/products created in secondary languages, you’ll need to manually restore the images in the page editor.

We've already completed all pending translations for the original US-en products.

Please note that in WooCommerce > WooCommerce Multilingual and Multicurrency > Products, you'll be able to which products were created in each language (check attached image on Andreas' previous reply). You'll also note that there are many French Products that have missing images (due to the same reason as pages created in secondary languages).

Following these steps will solve the problem. If you have any issues or questions about specific translations, please let us know so we can assist you. We understand this might not be your preferred solution, but it’s the quickest and most effective way to resolve the problem. Your cooperation is greatly appreciated.
Regarding the pages with the 404 error, please update them in the respective ticket. I checked, and Itamar is on standby for second-tier support. He will respond as soon as possible.

For the English page with Spanish images: hidden link, I checked the source code for both gallery and on-page images, and they have their meta-information in English, as expected. If I’m missing something, please send me a screenshot of the exact error. If necessary, we can create a separate ticket for it.

Thank you and best regards,

Edit Page _Accessoires de baignoire walk-in et add-ons_ _ Ellas Bubbles Walk In .jpeg
July 11, 2024 at 1:37 pm #15935427

tannerT

Hi Lucas, diving right in:

1.) I can confirm that this NO CONTENT was created in the french Canadian language individually, and all originated from .com. This sounds like it may be another issue in itself (I originally had a ticket to retranslate the site from scratch and start over due to all of this misconfiguration and evident issues with previous versions of your plugin). Anyway, we expect all of these product and all of these pages to be properly identified as translated versions of their original .com page. I am 110% confident (as the CMO of Ella's Bubbles) that no individualized content was drafted for French Canada, and 110% of the content is a direct translation of .com

2.) From which page am I clicking "Update Needed"? The Translation Editor Accesible via pages? Are you intending that I take this action for over 600 pages? Please be more elaborate in your suggestions and replies for actions that are needed to be taken. You mention "We've already completed all pending translations for the original US-en products." What about Pages as well? Please feel free to proceed with resolutions instead; we are simply looking for resolutions to issues that are incurred from your plugin; and do not care to learn troubleshooting for issues that should not have otherwise occured. A query to "bulk complete updating" is preferred. No Credits Should be spent in this process

3.) There is no update from Itamar at this time. Right now we have the issues of:

a.] Itamar Ticket
b.] Images Issue [Identified Here]
c.] Improper synchronization of translated pages (French Canada) <-

Shall I open a third and in depth ticket regarding c? As it seems that we are going to be inside of a downward spiral of discovering more and more problems and inevitably take 10-20+ hours of support time (likely more, feel free to look at our number of tickets) until this issue is resolved. As mentioned, we are more than willing to "wipe out WPML" and restart at no expense to us. Or, if you prefer to continue to try to fix (and identifying more problems like the French Canada) along the way, I will continuously spiral into unlimited ticket creation that reaches your Second-Tier support and press this matter as absolutely hard as we need to for immediate resolutions.

As you can tell, we are tired of the issues imposed by your plugin, as well as the "open ended support in the past"; and have assigned a designated representative from our company who will be taking as many hours as absolutely possible until this plugin is 110% prestine on our website.

The ball is back in your court,

July 11, 2024 at 1:43 pm #15935568

tannerT

4.) Your original code created hundreds of OEM Responses here shown at: hidden link

I will also await a resolution to this additionally imposed problem (To clarify, that resolution will be to remove them, in bulk, preferably without any additional labor required on our end)

Screenshot 2024-07-11 at 8.42.43 AM.png
July 12, 2024 at 8:04 pm #15944373

Bobby
Supporter

Languages: English (English )

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

Hi there,

I have reviewed your previous support threads and cannot locate a specific ticket where our team recommended deleting database entries. If you have a copy of this recommendation, please share it with me.

It is also important to note that whenever a major change is made, especially on the database, there should always be a backup available to use in case something goes wrong.

Do you have a backup from before these database changes were made? If yes, I recommend utilizing it, as there is no possible way of recovering these entries otherwise.

Here is the suggested workaround (we have tested this and it works):

1. Create a full website backup.

2. Complete all translations marked as "update needed" in the Translation Editor by clicking "Complete." This will restore the missing images.

3. For pages/products created in secondary languages, manually restore the images in the page editor.

Regarding the issues caused by running the script, the best course of action is to utilize a backup to revert those changes. This is why we always recommend having a backup before making any changes.

I understand this is not an ideal situation, but it is the recommended course of action.

July 15, 2024 at 2:29 pm #15954948

tannerT

Hi Bobby (the 3rd support representative for this case), I am not sure if my previous questions were blatantly ignored or too confusing to understand; but I am sending them here again in order so they can be answered as I have them. Otherwise, we can consider your support team as violation of TOS:

1.) From which page am I clicking "Update Needed"? The Translation Editor Accesible via pages? Are you intending that I take this action for over 600 pages? Please be more elaborate in your suggestions and replies for actions that are needed to be taken. You mention "We've already completed all pending translations for the original US-en products." What about Pages as well? Please feel free to proceed with resolutions instead; we are simply looking for resolutions to issues that are incurred from your plugin; and do not care to learn troubleshooting for issues that should not have otherwise occured. A query to "bulk complete updating" is preferred. No Credits Should be spent in this process

2.] Shall I open a third and in depth ticket regarding c? As it seems that we are going to be inside of a downward spiral of discovering more and more problems and inevitably take 10-20+ hours of support time (likely more, feel free to look at our number of tickets) until this issue is resolved. As mentioned, we are more than willing to "wipe out WPML" and restart at no expense to us. Or, if you prefer to continue to try to fix (and identifying more problems like the French Canada) along the way, I will continuously spiral into unlimited ticket creation that reaches your Second-Tier support and press this matter as absolutely hard as we need to for immediate resolutions.

July 15, 2024 at 2:29 pm #15954950

tannerT

And to properly answer your question (in an effort to demonstrate how that can be done); no; we are not interested to restoring to a backup from 8 months ago

July 15, 2024 at 2:30 pm #15954955

tannerT

FEEL FREE TO SIMPLY "RESOLVE THE ISSUE" AND THIS CASE CAN BE CLOSED

July 15, 2024 at 5:18 pm #15955905

Lucas Vidal de Andrade
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hey there,

We are working as a team on this ticket, as it is unusual to us to get this kind of situation - that's why you are receiving replies from more than one supporter. As I said previously, it requires a greater attention from our side.

Answering your questions, one by one:
From which page am I clicking "Update Needed"? The Translation Editor Accesible via pages? Are you intending that I take this action for over 600 pages?
Yes, this needs to be done to all your pages that have the spinning arrow symbol, which is the "update needed" status. If you have 600 pages with that status, that will need to be done to all 600 of them. You can see those pages in your Pages tab, in the WordPress admin panel. For other content (like products or posts), that have the same issue, the solution is the same.

You mention "We've already completed all pending translations for the original US-en products." What about Pages as well?
We updated the products to test the solution before hand. Any additional steps, to other content, must be done on your side.

we are simply looking for resolutions to issues that are incurred from your plugin;
As we said multiple times, the issue isn't incurred from WPML, but from the manual deletion of DB entries done by the user. This, as also said, was not advised by any WPML support agent. We reviewed older tickets. In case we are mistaken, you are welcome to send us information saying otherwise.

A query to "bulk complete updating" is preferred. No Credits Should be spent in this process
Unfortunately, we can't offer such query. By following the provided solution, no credits shall be spent.

Shall I open a third and in depth ticket regarding c?
Yes. To ensure every mentioned issue is properly addressed and that we can work in parallel, we need each issue to have its own ticket.

FEEL FREE TO SIMPLY "RESOLVE THE ISSUE" AND THIS CASE CAN BE CLOSED
As I said above: any additional steps, to other content, must be done on your side. Please let us know, or mark this ticket as resolved, when you're done fixing the deleted DB entries.

I'm available for any other questions you might have.

July 17, 2024 at 1:37 pm #15966580

tannerT

An absolute headache

tannerT confirmed that the issue was resolved on 2024-07-17 13:37:17.
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.