Skip Navigation

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

Problem:
The client was experiencing a fatal error when switching to Spanish content, with an error message indicating an 'InvalidArgumentException'
Solution:
We're not sure about what's causing the issue because our developers couldn't reproduce it on our servers but here is a quick workaround.

1. Access your server files using FTP or Cpanel.
2. Navigate to

wp-content/plugins/sitepress-multilingual-cms/classes/wp-core-hooks/post/

and edit the file named

class-wpml-remove-pages-not-in-current-language.php

.
3. Around line 34, locate the following line of code:

$filtered_posts = $posts;

4. Replace it with:

$posts = (isset($posts) && is_array($posts)) ? $posts : array();

This workaround should help you bypass the error.
If this solution doesn't look relevant to your issue, please open a new support ticket with us.

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 23 replies, has 3 voices.

Last updated by markW-54 1 year, 4 months ago.

Assisted by: Nicolas V..

Author Posts
November 29, 2023 at 3:37 pm #14953383

markW-54

This website is in English and Spanish (English is the primary language). The website is hosted on Siteground. No Siteground security or optimisation plugins are installed.

All English content can be viewed. However, when switching to Spanish content, the following error is shown:

Fatal error: Uncaught InvalidArgumentException: target should be an object with filter method or an array in /home/customer/www/website2023.ailespanol.com/public_html/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/fp/core/Fns.php:207 Stack trace: #0 [internal function]: WPML\FP\Fns::WPML\FP\{closure}(Object(Closure), false) #1 /home/customer/www/website2023.ailespanol.com/public_html/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/fp/core/functions.php(154): call_user_func_array(Object(Closure), Array) #2 /home/customer/www/website2023.ailespanol.com/public_html/wp-content/plugins/sitepress-multilingual-cms/classes/wp-core-hooks/post/class-wpml-remove-pages-not-in-current-language.php(48): WPML\FP\{closure}(false) #3 /home/customer/www/website2023.ailespanol.com/public_html/wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php(2284): WPML_Remove_Pages_Not_In_Current_Language->filter_pages(false, Array) #4 /home/customer/www/website2023.ailespanol.com/public_html/wp-includes/class-wp-hook.p in /home/customer/www/website2023.ailespanol.com/public_html/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/fp/core/Fns.php on line 207
Ha habido un error crítico en esta web.

Also - the site is exceptionally slow and I believe that the slowness is being caused by WPML attempting and failing to contact WPML's servers.

You can reproduce this error by visiting these two URLs:

English: hidden link
(should display correctly)
Spanish: hidden link
(will display the error)

I can provide you with access to the site, if required.

espanol-error.jpg
November 29, 2023 at 6:10 pm #14954859

Bobby
WPML Supporter since 04/2015

Languages: English (English )

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

Hello,

when you are logged in the backend, do you see a notice regarding the site being moved?

If possible, please click on ""This is a copy of my original site"" and save.

See following guides for details:

- https://wpml.org/documentation/translating-your-contents/advanced-translation-editor/using-advanced-translation-editor-when-you-move-or-use-a-copy-of-your-site/
- https://wpml.org/documentation/automatic-translation/using-automatic-translation-with-custom-languages/

Let me know your results, please.

November 29, 2023 at 9:14 pm #14956319

markW-54

Hi Bobby,

Thanks for getting back to me. You're correct in realising that the site has been moved, however that message about WPML detecting the move was not shown after the move and is still not shown.

The only related message I can see is on the WPML settings page, where the message "There is new translated content on this site. You can scan posts and strings to adjust links to point to translated content" is displayed.

We have moved two sites over to Siteground in the last week (they were originally hosted on WP Engine) - the Ail Espanol site we're discussing here and this one - hidden link.

We moved the Madrid site first and all went well - the site operates without error and no "WPML detected a new address for this site" message was displayed. As this migration went smoothly we carried out an identical migration for the Ail Espanol site, which unfortunately has not gone so well!

Is there any way to re-trigger the new address detection process?

All the best,

Eamonn

November 29, 2023 at 10:22 pm #14956657

Bobby
WPML Supporter since 04/2015

Languages: English (English )

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

Hi Eamonn,

Thank you for updating me, yes there is a way to trigger that, please see this documentation:

https://wpml.org/documentation/translating-your-contents/advanced-translation-editor/using-advanced-translation-editor-when-you-move-or-use-a-copy-of-your-site/#using-wpml-on-two-domains

November 29, 2023 at 10:45 pm #14956677

markW-54

Hi Bobby,

If I understand the documentation, I see that it is instructing me to log into the source copy of the site (in my case, this is the copy of the site on WP Engine - hidden link) and mark that site as a copy. Unfortunately, the "This site has moved to a new location" message is not displayed on this site either, so I am not able to carry out this procedure.

I should have said earlier - before raising the support ticket I registered the new site with WPML (the key is sxT8eMxZIg). I did this in case the error we're seeing was related to lack of an up to date key.

Thanks,

Eamonn

November 30, 2023 at 6:44 pm #14966487

Bobby
WPML Supporter since 04/2015

Languages: English (English )

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

Thank you, Eamonn,

I would like to request temporary access (wp-admin and FTP) to your site to test the issue.
(preferably to a test site where the problem has been replicated if possible)

**Before we proceed It is necessary to take FULL BACKUP of your database and your website. Providing us with access, you agree that a backup has been taken **

I often use the Duplicator plugin for this purpose: http://wordpress.org/plugins/duplicator/
You will find the needed fields for this below the comment area when you log in to leave your next reply.
The information you enter is private which means only you and I have access to it.

NOTE: If access to the live site is not possible and the staging site does not exist please provide me with a duplicator package created with the duplicator plugin.

December 1, 2023 at 9:44 pm #14976327

Bobby
WPML Supporter since 04/2015

Languages: English (English )

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

Thank you for the access details!

I can see that you are currently using the Classic Translation Editor and not the Advanced Translation Editor with the automatic translation.

Is this correct? (You can see the selection in WPML->Settings )

Also, when switching to Spanish where does the error occur, at the moment the dashboard is showing OK as well as the translation of the homepage

December 4, 2023 at 12:01 am #14981555

markW-54

Hi Bobby,

Yes - we're using the classic editor. The site uses the Divi theme with lots of custom layouts - pages often differ in structure and content between languages, hence the advanced editor isn't appropriate for our use case. Also, the site is being populated by bi-lingual English/Spanish speakers, hence there is no need for the site to manage translation jobs - the content editors are able to manage translation as they create pages.

Other than poor performance, the site displays no errors on the back end. As I mentioned in my initial email, the site works fine when viewing English content. The error is seen when switching to Spanish on the front end for any page other than the home page, for example:

English: hidden link
(should display correctly)
Spanish: hidden link
(will display the error)

All the best,

Eamonn

error.jpg
December 5, 2023 at 12:39 am #14992039

Bobby
WPML Supporter since 04/2015

Languages: English (English )

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

I can reproduce it now, thank you for the clarification.

If you believe the performance issue is caused by WPML, we can debug this further I will just have to split it into its ticket to keep each issue separated.

-----------------------------------------------------------------------

1. Regarding the fatal error issue, I have done a few tests and at the moment it looks like some pages are working ok and some are not.

For example : hidden link -- working OK

where : hidden link triggers the Error.

2. To your knowledge Is there any custom work applied to specific pages that could be causing some compatibility issues and triggering the fatal error?

3. When switching the theme to Divi instead of the custom child theme some pages are working OK such as the one I mentioned above.

4. Additionally, I was able to trigger the warning about the site moving by going to WPML->Settings-> switch to Advanced Translation Editor -> once I did that the warning popped up and was able to select that the site is a copy and switch back to the classic editor.

there were some updates that needed to happen which I let run and then I cleared any pending work in the automatic translation queue before switching to the Classic Translation Editor

Is this issue happening also on the live site or just on the production site?

Screen Shot 2023-12-04 at 4.09.50 PM.png
December 5, 2023 at 7:39 am #14993289

markW-54

Hi Bobby, thanks for the update.

In answer to your points:

1) That's very interesting - I hadn't been able to find any working Spanish pages.
2) There is no custom code specific to any particular pages and also there is no code on this site that isn't also present on this site, which works perfectly - (hidden link). The site we're having problems with is a direct copy of this perfectly functioning site.
3) To be clear, do you mean that these pages DO work using Divi an DO NOT work with the child theme?
4) That's a very interesting message. The source site it mentions (ailtemplate.wpengine.com) is not this site's immediate ancestor. Indeed, it does not even exist any more. Did you run this function? The second option ("I changed the address...") would be the correct option.

We're not seeing this problem with any of our other other WPML sites. Nor are we seeing performance issues with any of our WPML sites - hence the presumption that the two issues are related.

All the best,

Eamonn

December 5, 2023 at 3:39 pm #15000453

markW-54

Hi Bobby,

I have done some more testing and I have a bit more info for you:

1) I made another copy of the site (I used Duplicator to migrate a copy of ailespanol2023.wpenginepowered.com to a new instance on Siteground). This new copy can be seen at hidden link

2) The site is again extremely slow. The source site on WP Engine was not slow. Other highly similar sites in our Siteground account are not slow.

3) In this new copy's WPML->Settings the "have you moved this site" message was not shown

4) I triggered the message using the procedure you described - I changed the site to use the advanced translation editor, which caused the message to appear. I confirmed that this is a new site, then set the site back to use the classic editor.

4a) When I set the site to use the advanced editor, a message "can't connect to translation services" was displayed.

5) The same error is visible on the front-end of the site:
This works: hidden link

This produces the error: hidden link

(these pages are translations of each other)

Hope this is useful additional data for you.

All the best,

Eamonn

December 5, 2023 at 6:37 pm #15001981

Bobby
WPML Supporter since 04/2015

Languages: English (English )

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

Hi Eeamonn,

I appreciate your feedback and creating a new migration as I was wondering if possibly the environment was corrupted during migration.

Please try this:

Go to WPML->Settings->Switch to the advanced translation editor -> at the very top in the topbar there is the WPML icon -> hover over it do you see any pending tasks? If yes let it finish and then switch back to the classic editor this should help resolve the performance issue

Also, the next step is for us to escalate this issue to our second tier support for further debugging as I was not able to pinpoint the exact cause of the fatal error in the secondary language.

I have enabled the private reply field again (old access not working), I will take a duplicator package once i have access again

December 5, 2023 at 7:53 pm #15002515

markW-54

Hi Bobby,

Thanks for the suggestion. I've done as you suggested and switched to the advanced editor and checked for pending tasks. On the site you've been looking at, no WPML icon was displayed (see screenshots). On the site I made today, the icon was shown but no pending jobs existed

Thanks for referring this to your colleagues. Your access details for website2023.ailespanol.com are:

[removed]

All the best,

Eamonn

Untitled-1.png
December 6, 2023 at 7:25 pm #15011793

markW-54

Hi Bobby,

I've been doing some more testing on hidden link. I am sure your supposition is correct. I think the problem we're seeing is because a number of pages seem to be stuck in a state where the site thinks a translation job is in progress. The Accommodation page is a notable example - it is in the state "Needs translation". I've tried to do a manual translation on it, but this does not appear to be possible - either through the translation manager or by opening the page for editing and using the translation tools provided.

I can see you have run at least one translation job yourself - "The School" appears to have been run through the translation manager on 5th December, so I assume this was you.

Is there any way you can re-set the status of all currently translated pages? My supposition is that if all currently translated pages were set to the status "translated", it may fix the issue.

Eamonn

December 6, 2023 at 7:49 pm #15011959

markW-54

Further testing. I just set the site to use the advanced translation editor and did a manual translation of the "Accommodation" page. The translation editor worked fine and I was able to enter Spanish translations for all English elements of the page.

The process seemed to complete successfully and no errors were displayed while editing or while saving. The page now shows the pencil (edit translation) icon in the WordPress page listing. However, if I try to view the page on the front end or try to edit the Spanish translation using the WordPress page editor on the back end, I am still shown the error

"Fatal error: Uncaught InvalidArgumentException: target should be an object with filter method or an array in /home/customer/www/website2023.ailespanol.com/public_html/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/fp/core/Fns.php:207"