[Resolved] Error Triggered During CDB Form Translation (WPML 4.7.6)
This thread is resolved. Here is a description of the problem and solution.
Problem: The client reported a bug in WPML version 4.7.6 where an error occurs when clicking the '+' button on a page with custom fields. The error message displayed is: 'Uncaught TypeError: array_keys(): Argument #1 ($array) must be of type array.' This issue was linked to the handling of XML configurations for serialized custom fields. Solution: We identified that the XML file for the custom forms was misconfigured. Specifically, the 'optinText' field was expected to directly provide a text value for translation, but it was actually stored inside an array. To resolve this, we adjusted the XML configuration to correctly map the 'optinText' field as follows:
After modifying the XML and clearing any existing translation jobs for this form, the error was resolved, and the translation process proceeded without issues. We recommend the client to apply this XML configuration change and verify the results.
If this solution does not apply to your situation, or if it seems outdated, please check the related known issues and confirm that you have the latest versions of themes and plugins installed. If the problem persists, we highly recommend opening a new support ticket at WPML support forum.
100% of people find this useful.
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.
thanks, to be fair I am not sure why. If the plugin is built correctly, WP will recognize it and you can activate it.
If you re-upload correct files, and since this is already taking a while maybe best is to further check with developer who built the plugin, as I have said we will check but we can not guarantee we will debug and fix issue with custom plugin.
I am afraid I can not, since it is test site / server, this should be only used for simple tests / reproduction, not debugging of the issue and similar so we do not have server access.
I can only provide a new test site that you can use:
Thanks a lot Drazen, I'm almost done, I understood the error that my colleague encountered because I replicated it, so please could you provide another sandbox env or reset the current one ?
Thanks
sure, but I would suggest first trying on local and making sure you can show us WPML bug with simple example or similar, as I have said we can no debug your whole custom coded plugin. Then you can reproduce same thing on test site.
Thank you Drazen,
You totally right and it is what I've done without no issue, but in fact I think there was an issue while unzipping the zip archive.
Those testing are already on more than 200 website running fine so I think the issue came from the file manager
I do not want to make you lose your time but I need another one sandbox please, thanks for your comprehension.
Drazen, I finally was able to setup the environment for you to replicate the issue
on this page hidden link click on the "+" link as if you wanted to translate the test form, you will get the fatal error that I mentioned at the beginning of my thread, then if you go back you will have the gear icon, but from there we have no way or workaround for translating the post.
So, please advise what we could do, please tell me if your dev team can adapt the wpml plugin or if there is a workaround
Thanks
The problem is that you have created an XML file for these custom forms which are slightly mis specified.
On this test site the form has a post ID of 78, and if we check the entry in wp_postmeta for _pr_cdb_form and pass the value into an unserializer then we get a lot of data , so let's focus on the problem field that triggers the error, optinText:
Note that the text is not stored as a direct property of optinText, it is stored in an array.
The plugin has a custom XML file, note how it expects optinText to directly provide the text value for translation, but as noted above it is inside an array.
So that particular part of the XML config should be:
We have modified the custom XML, and made sure to delete any existing jobs for this form, then when we tried again to translate we didn't encounter any errors.
Hello Drazen, thanks for your feedback, however when I want to try what you suggested I cannot reach the sandbox anymore whereas I did not do any modification since last time
hidden link
I get the fatal error saying that a file is missing whereas I did not remove it ?