Skip to content Skip to sidebar

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

Problem:
If you're experiencing a fatal error stating 'Cannot use object of type stdClass as array' in sitepress-multilingual-cms/classes/localization/class-wpml-download-localization.php, it might be due to a conflict with Duplicator Pro plugin. This occurs because the translations_api filter should return an array, but Duplicator Pro sometimes returns an object, causing WPML to treat it incorrectly.
Solution:
We recommend deactivating Duplicator Pro to see if the issue resolves. If it does, you can apply a temporary fix by modifying the code in wp-content/plugins/duplicator-pro/src/Utils/Translations.php. Replace the problematic line with the following code:

return $this->getTranslations($args['slug'], $this->apiUrl);

With:

$translations = $this->getTranslations($args['slug'], $this->apiUrl);<br />// Ensure we return an array, not an object (WordPress expects array)<br />if (is_object($translations) && isset($translations->{ $args['slug'] })) {<br />    return $translations->{ $args['slug'] };<br />}<br />return is_array($translations) ? $translations : [];

We also suggest reporting this issue to Duplicator Pro support for a permanent fix. If this solution does not resolve your issue or seems irrelevant due to being outdated or not applicable to your case, please check related known issues at https://wpml.org/known-issues/, verify the version of the permanent fix, and confirm that you have installed the latest versions of themes and plugins. If further assistance is needed, we highly recommend opening 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.

This topic contains 5 replies, has 0 voices.

Last updated by aitorZ 1 week, 3 days ago.

Assisted by: Noman.

Author Posts
December 14, 2025 at 3:22 pm #17662188

aitorZ

Environment: PHP 8.3, WPML Multilingual CMS (latest), WordPress X.X
Error:
Fatal error: Cannot use object of type stdClass as array
in
sitepress-multilingual-cms/classes/localization/class-wpml-download-localization.php:136

Cause:
translations_api() may return an object (stdClass), but WPML treats it as an array:

if ( empty( $api['translations'] ) ) {

Temporary fix:
Casting $api to array after is_wp_error() check:

if ( is_object( $api ) ) {
$api = (array) $api;
}

This prevents the fatal error and all

December 15, 2025 at 11:59 am #17663983

Noman
WPML Supporter since 06/2016

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

To isolate the cause of this issue, I have set up a fresh WP site on a test server(cloudways). Please migrate your site there using the details I shared in my earlier private reply, and let me know once the migration is complete.

Please provide temporary access (WP-Admin Login info) to the migrated site, so that I can look into your setup and debug the issue.

Your next answer will be private, meaning only you and I can access it.

Thank you for your cooperation

December 16, 2025 at 5:44 pm #17668837

Noman
WPML Supporter since 06/2016

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thanks for installing the Duplicator package on a fresh WordPress site.

I can see a critical error when trying to save the languages. I followed these steps:
1. Went to WPML >> Support.
2. Click on the Troubleshooting link.
3. Click on the “Reset languages” button.

After that, I was able to update the languages without any errors.

Please note that this action will remove any customizations made under WPML → Languages → Edit Languages. You may need to add those labels again using the translation text boxes.

Could you please take a full backup of your site and try the same steps on your side to see if this resolves the issue?

Thank you

Reset languages button.jpg
troubleshooting page12.jpg
December 17, 2025 at 9:25 am #17670252

aitorZ

Thanks for the detailed steps.

I have already followed exactly the same procedure on my side:

– Full site backup taken
– WPML → Support → Troubleshooting
– Clicked Reset languages

Unfortunately, the fatal error still occurs when saving the languages after the reset.

So in my case, resetting the languages does not resolve the issue.

Important notes:
– The error is reproducible on this site consistently
– It does not happen on a fresh WP install
– The temporary fix you mentioned (casting $api to array) confirms this is a WPML-side handling issue when translations_api() returns an object instead of an array

At this point, I believe this is either:
– a data-related edge case triggered by a real-world site, or
– a regression affecting certain environments / plugin combinations

Could you please escalate this to the WPML developers for deeper analysis using the provided Duplicator package?

I’m happy to provide any additional logs or testing if needed, but I’d prefer not to dismantle a production-like setup plugin by plugin.

Thank you.

December 17, 2025 at 5:44 pm #17672221

Noman
WPML Supporter since 06/2016

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thanks for the detailed explanation, that’s very helpful.

I’ll install the provided Duplicator package on my local environment to reproduce the issue and rule out any local factors. If the error persists there as well, I’ll escalate this to the 2nd tier support with full context and the package for deeper analysis.

I’ll keep you posted on the progress. Thank you for your patience.

December 18, 2025 at 8:31 pm #17676196

Noman
WPML Supporter since 06/2016

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thanks for your patience.

I tested the site in a minimal setup (default WordPress 2025 theme and only WPML active), and the issue no longer occurs. I then reactivated plugins one by one and identified Duplicator Pro as the cause. When Duplicator Pro is deactivated, everything works correctly.

This is a known issue. According to WordPress documentation, the translations_api filter must return an array, but Duplicator Pro sometimes returns an object, which triggers the fatal error.

You can correct it as follows:
In the file wp-content/plugins/duplicator-pro/src/Utils/Translations.php

Replace line 88:

return $this->getTranslations($args['slug'], $this->apiUrl);

With:

$translations = $this->getTranslations($args['slug'], $this->apiUrl);
// Ensure we return an array, not an object (WordPress expects array)
if (is_object($translations) && isset($translations->{ $args['slug'] })) {
    return $translations->{ $args['slug'] };
}
return is_array($translations) ? $translations : [];

I tested this change locally and it works.

For a permanent fix, I strongly recommend reporting this to Duplicator Pro support, as the issue needs to be fixed on their side.

Related ticket link(Spanish): https://wpml.org/es/forums/topic/fatal-error-al-anadir-un-nuevo-idioma-personalizado/

Please let me know if this resolves the issue or if you need further assistance with this issue.

Thank you

December 20, 2025 at 8:44 am #17679611

aitorZ

Thanks for the clarification and for reproducing the issue.

That makes sense now. I agree this is a Duplicator Pro issue returning an object instead of an array to translations_api.

I’ll report this to Duplicator Pro support so they can fix it permanently on their side.

For now, I’ll avoid patching core plugin files and use a workaround when needed.

Thanks again for the thorough investigation.