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.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 -
- 12:00 – 16:00 12:00 – 16:00 12:00 – 16:00 12:00 – 16:00 12:00 – 16:00 -

Supporter timezone: Europe/Zagreb (GMT+02:00)

This topic contains 6 replies, has 3 voices.

Last updated by Dražen 3 years, 12 months ago.

Assisted by: Dražen.

Author Posts
May 18, 2021 at 5:24 pm #8793885

benR-2

I am trying to:
Edit a custom field in the main language.

Link to a page where the issue can be seen: /local

I expected to see:
The custom field updated in the translated product.

Instead, I got:
A custom field added to the translated post. Not a modified one.

The problem seems to be in class-wpml-sync-custom-fields.php.

The $removed array looks like this:

Array
(
    [0] => {"cuwzrcfofpsphjgslmbe":{"label":"10:00","hour":"10","minute":"00","period":"","add_time":"enabled","eegqepwzbupzfqzuhzay_add_date":"30\/05\/2021","eegqepwzbupzfqzuhzay_stock":""},"dtacvjrfizwlfhmvfpdp":{"label":"11:00","hour":"11","minute":"00","period":"","add_time":"enabled","myiyrslahmjpqoqylypm_add_date":"30\/05\/2021","myiyrslahmjpqoqylypm_stock":""},"ddwibilzpuhfamfiovga":{"label":"12:00","hour":"12","minute":"00","period":"","add_time":"enabled","rgtkenlplvkljlepbviw_add_date":"30\/05\/2021","rgtkenlplvkljlepbviw_stock":"","hufkezjzqkggefaliaya_add_date":"31\/05\/2021","hufkezjzqkggefaliaya_zoom_id":"","hufkezjzqkggefaliaya_stock":""}}
    [1] => {"cuwzrcfofpsphjgslmbe":{"label":"10:00","hour":"10","minute":"00","period":"","add_time":"enabled","eegqepwzbupzfqzuhzay_add_date":"30\/05\/2021","eegqepwzbupzfqzuhzay_stock":""},"dtacvjrfizwlfhmvfpdp":{"label":"11:00","hour":"11","minute":"00","period":"","add_time":"enabled","myiyrslahmjpqoqylypm_add_date":"30\/05\/2021","myiyrslahmjpqoqylypm_stock":""},"ddwibilzpuhfamfiovga":{"label":"12:00","hour":"12","minute":"00","period":"","add_time":"enabled","rgtkenlplvkljlepbviw_add_date":"30\/05\/2021","rgtkenlplvkljlepbviw_stock":"","hufkezjzqkggefaliaya_add_date":"31\/05\/2021","hufkezjzqkggefaliaya_stock":"","udoncyccgtosnxmxitgy_add_date":"20\/05\/2021","udoncyccgtosnxmxitgy_zoom_id":"","udoncyccgtosnxmxitgy_stock":""}}
    [2] => {"cuwzrcfofpsphjgslmbe":{"label":"10:00","hour":"10","minute":"00","period":"","add_time":"enabled","eegqepwzbupzfqzuhzay_add_date":"30\/05\/2021","eegqepwzbupzfqzuhzay_stock":""},"dtacvjrfizwlfhmvfpdp":{"label":"11:00","hour":"11","minute":"00","period":"","add_time":"enabled","myiyrslahmjpqoqylypm_add_date":"30\/05\/2021","myiyrslahmjpqoqylypm_stock":""},"ddwibilzpuhfamfiovga":{"label":"12:00","hour":"12","minute":"00","period":"","add_time":"enabled","rgtkenlplvkljlepbviw_add_date":"30\/05\/2021","rgtkenlplvkljlepbviw_stock":"","hufkezjzqkggefaliaya_add_date":"31\/05\/2021","hufkezjzqkggefaliaya_stock":"","udoncyccgtosnxmxitgy_add_date":"20\/05\/2021","udoncyccgtosnxmxitgy_stock":"","vttndalhnmjqvpalxkas_add_date":"21\/05\/2021","vttndalhnmjqvpalxkas_zoom_id":"","vttndalhnmjqvpalxkas_stock":""}}
)

But

foreach ( $removed as $v ) {
  delete_post_meta( $post_id_to, $meta_key, maybe_unserialize( $v ) );
}

Does not remove anything.

Kind regards,
Ben

May 19, 2021 at 4:02 pm #8802191

Itamar
WPML Supporter since 02/2016

Languages: English (English )

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

Hi,

Before your ticket is assigned to one of my colleagues, please allow me to walk you through some initial debugging steps. This will help speed up the support process.

Please ensure that you are following our instructions at the following link on how to work with WPML and the ACF plugin.

https://wpml.org/documentation/related-projects/translate-sites-built-with-acf/

It is important to know that we have a bridge plugin called ACF Multilingual that you must install when working with the ACF plugin. I can see that it is not active on your site.

Regards,
Itamar.

May 19, 2021 at 5:37 pm #8802649

benR-2

Hi, the custom field is created by a plugin... a simple custom field with a strange content 🙂

Anyway, as a temporary fix I used wpml_sync_custom_field_copied_value filter to edit and delete the fields before adding new ones.

...
$v = wp_slash( $v );
...

delete_metadata() is escaping double quotes and so $v is not as expected.

Kind regards,
Ben

May 20, 2021 at 7:17 am #8805451

Dražen
Supporter

Languages: English (English )

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

Hello Ben,

thanks for getting back, glad to hear you managed to find a workaround.

I am not sure I understand completely your issue here, but please note as per our policy we do not support custom coding solutions.

We will be glad to help and suggest an approach just we would need a bit more info about the plugin, code, and usage. Or if you think there is a WPML bug, together we will need to reproduce the issue on a clean test site and check on this with our developers.

Please let me know if you still need our assistance in this case or if you still have any questions.

Thanks,
Drazen

May 20, 2021 at 2:26 pm #8810285

benR-2

Hi,

it is very easy to reproduce.
Steps:
Create a custom field with the content:

{"cuwzrcfofpsphjgslmbe":{"label":"10:00","hour":"10","minute":"00","period":"","add_time":"enabled","eegqepwzbupzfqzuhzay_add_date":"30\/05\/2021","eegqepwzbupzfqzuhzay_stock":""},"dtacvjrfizwlfhmvfpdp":{"label":"11:00","hour":"11","minute":"00","period":"","add_time":"enabled","myiyrslahmjpqoqylypm_add_date":"30\/05\/2021","myiyrslahmjpqoqylypm_stock":""},"ddwibilzpuhfamfiovga":{"label":"12:00","hour":"12","minute":"00","period":"","add_time":"enabled","rgtkenlplvkljlepbviw_add_date":"30\/05\/2021","rgtkenlplvkljlepbviw_stock":"","hufkezjzqkggefaliaya_add_date":"31\/05\/2021","hufkezjzqkggefaliaya_zoom_id":"","hufkezjzqkggefaliaya_stock":""}}

I mean literally copy this in the database (postmeta) directly in the value field.
Set this custom field to copy in wpml settings.

Create a translation of this post.
Edit the custom field in the main language.
Check translation custom field and you will see it is not updated.
A new custom field is created for the translation, instead of the first being updated from the main language.

You can debug function sync_custom_field() in class-wpml-sync-custom-fields.php,
delete_post_meta(), and will see that it is not deleted, because of delete_metadata()...

I hope I explained the steps well enough. Let me know if you need any other info.

BTW, someone else got this problem before:
https://wpml.org/forums/topic/unnecessary-wp_slash-in-wpml_sync_custom_fields-breaks-sync-of-custom-fields/

Kind regards,
Ben

May 21, 2021 at 8:29 am #8816005

Dražen
Supporter

Languages: English (English )

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

Hello Ben,

thanks for getting back and explaining the issue to me, shared ticket was also very helpful.

I was able to reproduce the same issue, as explained.

I've escalated this ticket and issue to our developers team.

They are taking a look and I will let you know as soon as they have updated me.

Please note that this process may take a while.

Thank you for your patience.

Regards,
Drazen

May 31, 2021 at 5:55 am #8878549

Dražen
Supporter

Languages: English (English )

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

Hello Ben,

just to update you, the issue was confirmed by our developers and we will be working on a permanent fix and including it in one of the next versions of WPML.

As a workaround we suggest next:

- Complete backup of site files and DB.

- Edit \sitepress-multilingual-cms\classes\custom-field-translation\class-wpml-sync-custom-fields.php line number 63 and replace

delete_post_meta( $post_id_to, $meta_key, maybe_unserialize( $v ) );

with

delete_post_meta( $post_id_to, $meta_key, wp_slash( maybe_unserialize( $v ) )  );

I will update you when I have some news on the release of the version with the fix.

Thanks and kind regards,
Drazen