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:

After updating WooCommerce multilingual to 4.3.4 featured images from some products get removed. They get removed from the admin UI.

Solution:

If you have not updated your site to WooCommerce Multilingual 4.3.6, then you can use this patched WooCommerce Multilingual version to update on your site.

The patch is in this file /woocommerce-multilingual/inc/class-wcml-upgrade.php on line 706. The change is as followed.

Before the change:

    private function upgrade_4_3_4() {
        global $wpdb;

        //delete wrong duplicated attachments
        $wpdb->query( "DELETE FROM {$wpdb->prefix}icl_translations WHERE `element_id` IN ( SELECT ID FROM {$wpdb->prefix}posts WHERE `guid` LIKE '%attachment_id%' ) " );
        $wpdb->query( "DELETE FROM {$wpdb->prefix}postmeta WHERE `post_id` IN ( SELECT ID FROM {$wpdb->prefix}posts WHERE `guid` LIKE '%attachment_id%' ) " );
        $wpdb->query( "DELETE FROM {$wpdb->prefix}posts WHERE `guid` LIKE '%attachment_id%'" );

After the change:

private function upgrade_4_3_4() {
        global $wpdb;
 
        $affected_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->prefix}posts AS p LEFT JOIN {$wpdb->prefix}postmeta AS pm ON p.ID = pm.post_id WHERE p.`guid` LIKE '%attachment_id%' AND pm.meta_key = '_wp_attached_file' AND pm.meta_value = ''" );
        $affected_ids = join( ',', $affected_ids );
        //delete wrong duplicated attachments
        $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}icl_translations WHERE `element_id` IN ( %s )", $affected_ids ) );
        $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}postmeta WHERE `post_id` IN ( %s ) " , $affected_ids ) );
        $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}posts WHERE `ID` IN ( %s ) ", $affected_ids ) ) ;
 
    }


**** Important! Please make a full site backup (files and DB) before you proceed with those steps****

This topic contains 28 replies, has 3 voices.

Last updated by Itamar 1 year ago.

Assigned support staff: Itamar.

Author Posts
August 22, 2018 at 2:08 pm #2667047

Kresimir

After updating WooCommerce multilingual to 4.3.4 featured images from some products get removed. They get removed from the admin UI. The DB still has an entry so the function get_post_thumbnail_id returns the id but get_the_post_thumbnail doesn't return the image markup. I'm using Twenty Sixteen with just WPML required plugins and WooCommerce. Everything is updated to the latest version. Hope you can help.

August 22, 2018 at 9:31 pm #2668167

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi.

Can you please go to WPML -> Settings -> Media Translation (at the bottom of the screen) and select all the options and press the "start' button?
Please see the attached screenshot.

Is it solving the product images issue that you are having?

Regards,
Itamar.

August 23, 2018 at 7:39 am #2668945

Kresimir

There is no option like that on that page. Here is a screenshot (hidden link) how this screen looks in the admin.

August 23, 2018 at 10:39 am #2669720

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi.

I'm sorry, the screenshot that I've shared with you is old.
Now the Media Translation options are in WPML -> Settings as I wrote.
Please see the attached screenshot.

Regards,
Itamar.

August 23, 2018 at 12:44 pm #2670171

Kresimir

Tried it. Still not working. The old products didn't get their featured image back.

August 23, 2018 at 11:07 pm #2671746

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi and thanks for trying that.

Can you please let me have access to your site so I can examine the issue?
Please also tell me where to go to see the issue.

I would like to request temporary access (wp-admin and FTP) to your site to take a better look at the issue. It would be better to a testing site where the issue is replicated.
You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.
Maybe I'll need to replicate your site locally. For this, I’ll need to temporarily install a plugin called “Duplicator” on your site. This will allow me to create a copy of your site and your content. Once the problem is resolved, I will delete the local site. Let me know if this is ok with you.
** IMPORTANT **
- Please make a backup of site files and database before providing us access.
- If you do not see the wp-admin/FTP fields, this means your post & website login details will be made PUBLIC. DO NOT post your website details unless you see the required wp-admin/FTP fields. If you do not, please ask me to enable the private box. The private box looks like this:
hidden link

Thanks,
Itamar.

August 26, 2018 at 8:52 pm #2676520

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi, and thank you for the access details.

I think that this issue is a known issue that we currently have and is already fixed in the upcoming version of WooCommerce Multilingual. This issue is mentioned in the following forum tickets.
https://wpml.org/forums/topic/woocommerce-variable-product-thumbnails-are-out-of-sync/
https://wpml.org/forums/topic/some-of-my-medias-dont-appear/page/2/
Could you confirm that the issue is happening with variable products?
And could also confirm that changing an image on a variation does not reflect the change in translation of that variation?

The next versions of WPML and all the add-ons with the fix should be published in the next few days. In the meantime, if you have a testing version of the site, you can test the beta version to see if it solves this issue.

You can find the beta version in the "Beta" channel of our Downloads page here:
https://wpml.org/account/downloads/ You will need to update all of our plugins.

**** Important! Please make a full site backup (files and DB) before you proceed with those steps****


*** Do not use the beta version on a live site.***

Thanks,
Itamar.

August 27, 2018 at 8:25 am #2677294

Kresimir

No the issue is happening on simple product types also. Also I discovered that after the plugin update the media entries get deleted from media library.

August 27, 2018 at 8:51 pm #2679956

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi.

I've made a copy of your site and installed it on my local server.
Installing it to be able to access the admin required some tweaks in the wp-config.php file.

I'll be able to continue debugging this issue tomorrow.

Thank you for your patience.
Itamar.

August 28, 2018 at 7:36 pm #2684016

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi.

I have your site installed now on my local server (I still needed to make a lot of tweaks to make it work).
Even before I update WPML and its add-ons I see a lot of product images that are missing.
Please see the attached screenshots.

I think that the issue might be related to caching and collision with other plugins.
Could טםו please try to see, if before you update WPML, you get the images missing when you clear all the cache from your site and server and deactivate all the other plugins including mu-plugins?
This way we'll know if it is a cache or other plugin issue.
The current state of your site on my local server is without cache and all the other plugins deactivate or removed from the plugins folder.

Thanks,
Itamar.

August 29, 2018 at 12:26 pm #2686350

Kresimir

Hey Itamar, here are my answers on your questions:

Even before I update WPML and its add-ons I see a lot of product images that are missing.
Those products don't have a featured image intentionally. The issue we're experiencing is that WooCommerce Multilingual removes media entry from the media library but the info about the featured image is still preserved so there is still an ID which get's returned via get_post_thumbnail_id function. But there is no media entry. Because of that after we update WooCommerce Multilingual and the bug happens the list of products doesn't have the default WooCommerce placeholder like it does on your screenshot. Here is a screenshot of the admin after the update: hidden link. Pls check my first post about the issue for further clarification or get back to me if you have any other questions about the issue.

I think that the issue might be related to caching and collision with other plugins.
Could טםו please try to see, if before you update WPML, you get the images missing when you clear all the cache from your site and server and deactivate all the other plugins including mu-plugins?
This way we'll know if it is a cache or other plugin issue.
The current state of your site on my local server is without cache and all the other plugins deactivate or removed from the plugins folder.

The only plugins active are WooCommerce, WooCommerce Multilingual, WPML and all WPML required plugins and Duplicator. No caching plugins are active. There is a drop-in (advanced-cache.php) bit it's not active since WP_CACHE is set to default as you can see in the admin (screenshot: hidden link). But I tried the update on my local install and I removed the drop in and the same thing happened.

I did the update of all WPML plugins and updated WooCommerce Multilingual to 4.3.5 but the issue is still present after the update.

Also can you pls try to do the WooCommerce Multilingual update on your local install and confirm if you can recreate the issue? Right now I created the issue on both my local install and on the staging server.

August 29, 2018 at 10:08 pm #2687964

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi.

Yes, I can see the issue when I update WooCommerce Multilingual to the latest version (4.3.5 currently). I'm discussing this issue with our second tier supporters and get back to you here when I have more instructions from them.

Regards,
Itamar.

August 30, 2018 at 6:57 pm #2691683

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hey.

I've consulted our second tier supporter about this issue. He told me that we have update logic that removes bad attachments in the latest versionsWooCommerce Multilingual. This is the logic.

	private function upgrade_4_3_4() {
		global $wpdb;

		//delete wrong duplicated attachments
		$wpdb->query( "DELETE FROM {$wpdb->prefix}icl_translations WHERE `element_id` IN ( SELECT ID FROM {$wpdb->prefix}posts WHERE `guid` LIKE '%attachment_id%' ) " );
		$wpdb->query( "DELETE FROM {$wpdb->prefix}postmeta WHERE `post_id` IN ( SELECT ID FROM {$wpdb->prefix}posts WHERE `guid` LIKE '%attachment_id%' ) " );
		$wpdb->query( "DELETE FROM {$wpdb->prefix}posts WHERE `guid` LIKE '%attachment_id%'" );

I've checked it on the copy of your site and before the updated of WooCommerce Multilingual you had 1040 such trashed attachments. The query that I've made is this.

SELECT * FROM wp_posts WHERE guid LIKE '%attachment_id%'

Indeed after the update those attachments are deleted. So I can say that this behaviour is expected.

Please let me know f you need further clarifications on this issue.

Regards,
Itamar.

August 31, 2018 at 9:59 am #2693179

Kresimir

Hey Itamar,

thnx for your reply but this kinda opens more questions than it answers:

1. I ran your query but the posts the query returns are not trashed posts. Their post status is set to inherit. They are just posts which guid has their own ID inside. Also I don't know how we could have trashed them since we didn't define MEDIA_TRASH constant. All of the media files on the site get permanently deleted. The snippet you posted states that the function deletes wrongly duplicated attachments, not trashed attachments. I'm just pointing this out so we are on the same page about attachments that get deleted by the update are not trashed but wrongly duplicated.

2. It would be great if you can explain in detail what caused the attachments to get wrongly duplicated. Since there is a fix for that in your plugin this is probably an issue you encountered which prompted you in adding the fix in the first place.

3. You wrote that this is an "expected behaviour" but there is still a problem of media files being deleted which were wrongly duplicated but are used by posts/products. Surely this can't be the desired functionality leaving posts without their featured images or images inside post content after the update. Is there a fix for that issue?

Hope you can help

September 3, 2018 at 7:32 pm #2700808

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hy and sorry for the late reply here.

I get your point, and it might be that you have a different setup that our developers did not account for. I've asked our second tier supporter to read your comment and tell me what he thinks. I'll keep you updated here.

Thanks,
Itamar.