Skip Navigation

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

Problem:
I'm trying to migrate data from Polylang to WPML but the migration is hanging. I check the debug log and see this error
PHP Fatal error: Uncaught TypeError: Cannot access offset of type string on string in .../wp-content/plugins/migrate-polylang-to-wpml-0.4/classes/class-mpw_migrate_posts.php:89
Solution:
This issue happens when using PHP 8.0, to fix this issue, please follow steps below:

- Create a backup of your database and website before proceeding.

- Edit the file: /wp-content/plugins/migrate-polylang-to-wpml-0.4/classes/class-mpw_migrate_posts.php in your WordPress directory.

- Find the following code:

list($trid, $post_type) = $this->set_original_post_language_details($relation, $default_language_code);

replace it with this one:

if( !is_array( $relation ) ) {
    continue;
}

list($trid, $post_type) = $this->set_original_post_language_details($relation, $default_language_code);
 
if (count($relation) == 1) {
 continue;
}

- Find the following code:

$original_post_id = isset($relation['sync']) ? $relation['sync'][$default_language_code['polylang']] : $relation[$default_language_code['polylang']];

replace it with this one:

$original_post_id = (isset($relation['sync']) ? $relation['sync'][$default_language_code['polylang']] : isset($relation[$default_language_code['polylang']])) ? $relation[$default_language_code['polylang']] : reset($relation);
 
if ($original_post_id === NULL ) {
 $original_post_id = reset ($relation);
}

- Save the file and rerun the import.
Relevant Documentation:
https://wpml.org/documentation/related-projects/migrate-polylang-wpml/

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

Last updated by marcD-48 2 years ago.

Assisted by: Long Nguyen.

Author Posts
June 7, 2023 at 3:23 pm #13787889

marcD-48

I'm trying to migrate from Polylang over to WPML but the migration is stalling. Migration has been running for 4hrs and it still only displays the following

Migration started, please don't close this window...
Moving your language settings...
Language settings has been migrated
Setting languages for posts...

My site isn't big. It only has 34 pages, 30 blog posts, 345 images and 10 custom posts (using Crocoblock's JetEngine and suite of widgets). FYI, site is in production and I do not have staging capabilities. Also, not that I think it matters here but, I'm currently in the process of converting it to Elementor's new container model.

Right now, had to perform a restore from a complete backup in order to get my site back up and running.

WP installation and widgets are all up to date. Following is my system info

					
== Server Environment ==
	Operating System: Linux
	Software: Apache
	MySQL version: MariaDB Server v10.5.20
	PHP Version: 8.2.6
	PHP Memory Limit: 128M
	PHP Max Input Vars: 1000
	PHP Max Post Size: 100M
	GD Installed: Yes
	ZIP Installed: Yes
	Write Permissions: All right
	Elementor Library: Connected

== WordPress Environment ==
	Version: 6.2.2
	Site URL: <em><u>hidden link</u></em>
	Home URL: <em><u>hidden link</u></em>
	WP Multisite: No
	Max Upload Size: 100 MB
	Memory limit: 40M
	Max Memory limit: 512M
	Permalink Structure: /%postname%/
	Language: en-US
	Timezone: America/Toronto
	Admin Email: mdugre@datatelcom.com
	Debug Mode: Inactive

== Theme ==
	Name: Hello Elementor Child
	Version: 1.0.1
	Author: Elementor Team
	Child Theme: Yes
	Parent Theme Name: Hello Elementor
	Parent Theme Version: 2.7.1
	Parent Theme Author: Elementor Team

== User ==
	Role: administrator
	WP Profile lang: en_US
	User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/113.0

== Active Plugins ==
	Crocoblock Wizard
		Version: 1.2.3
		Author: Crocoblock

	Elementor
		Version: 3.13.4
		Author: Elementor.com

	Elementor Pro
		Version: 3.13.2
		Author: Elementor.com

	Ivory Search (Premium)
		Version: 5.5.1
		Author: Ivory Search

	JetBlocks For Elementor
		Version: 1.3.5
		Author: Crocoblock

	JetElements For Elementor
		Version: 2.6.10
		Author: Crocoblock

	JetEngine
		Version: 3.1.6.1
		Author: Crocoblock

	JetEngine - Custom visibility conditions
		Version: 1.1.0
		Author: Crocoblock

	JetEngine - dynamic tables builder
		Version: 1.0.7
		Author: Crocoblock

	JetEngine - Trim string callback
		Version: 1.0.0
		Author: Crocoblock

	JetFormBuilder
		Version: 3.0.8
		Author: Crocoblock

	JetPlugins Dynamic Data Addon
		Version: 1.3.1
		Author: Crocoblock

	JetPopup
		Version: 2.0.0
		Author: Crocoblock

	JetSearch
		Version: 3.0.3
		Author: Crocoblock

	JetSmartFilters
		Version: 3.1.2
		Author: Crocoblock

	JetTabs For Elementor
		Version: 2.1.21
		Author: Crocoblock

	JetTricks
		Version: 1.4.4
		Author: Crocoblock

	Polylang
		Version: 3.4.2
		Author: WP SYNTEX

	Polylang Connect for Elementor
		Version: 2.4.1
		Author: Creame

	Rank Math SEO
		Version: 1.0.116
		Author: Rank Math

	Rank Math SEO PRO
		Version: 3.0.37
		Author: Rank Math

	Really Simple SSL
		Version: 7.0.3
		Author: Really Simple Plugins

	Temporary Login Without Password
		Version: 1.8.2
		Author: StoreApps

	UpdraftPlus - Backup/Restore
		Version: 1.23.4
		Author: UpdraftPlus.Com, DavidAnderson

	Wordfence Security
		Version: 7.9.3
		Author: Wordfence

	WordPress Importer
		Version: 0.8.1
		Author: wordpressdotorg

	WP-Optimize - Clean, Compress, Cache
		Version: 3.2.15
		Author: David Anderson, Ruhani Rabin, Team Updraft

	WP Fastest Cache
		Version: 1.1.6
		Author: Emre Vona

	WP Mail SMTP
		Version: 3.8.0
		Author: WP Mail SMTP


== Features ==
	Custom Fonts: 0
	Custom Icons: 0

== Integrations ==
	
	recaptcha_v3: Active


== Elementor Experiments ==
	Optimized DOM Output: Active
	Improved Asset Loading: Active
	Improved CSS Loading: Active
	Inline Font Icons: Inactive
	Accessibility Improvements: Active
	Additional Custom Breakpoints: Active
	admin_menu_rearrangement: Inactive by default
	Flexbox Container: Active
	Upgrade Swiper Library: Inactive by default
	Grid Container: Inactive by default
	Default to New Theme Builder: Active
	Hello Theme Header & Footer: Inactive
	Editor Top Bar: Inactive by default
	Landing Pages: Inactive
	Nested Elements: Inactive
	Lazy Load Background Images: Inactive
	Page Transitions: Inactive
	Notes: Inactive
	Loop: Active
	Form Submissions: Active
	Scroll Snap: Inactive
	Menu: Inactive


== Log ==
	
Log: showing 20 of 322023-05-11 17:07:27 [info] elementor-pro::elementor_pro_updater Started 
2023-05-11 17:07:27 [info] Elementor Pro/Upgrades - _on_each_version Start  
2023-05-11 17:07:27 [info] Elementor Pro/Upgrades - _on_each_version Finished 
2023-05-11 17:07:27 [info] Elementor data updater process has been completed. [array (
  'plugin' => 'Elementor Pro',
  'from' => '3.13.0',
  'to' => '3.13.1',
)]
2023-05-11 17:07:27 [info] Elementor data updater process has been queued. [array (
  'plugin' => 'Elementor Pro',
  'from' => '3.13.0',
  'to' => '3.13.1',
)]
2023-05-11 17:07:28 [info] Elementor data updater process has been queued. [array (
  'plugin' => 'Elementor Pro',
  'from' => '3.13.0',
  'to' => '3.13.1',
)]
2023-05-23 08:06:44 [info] elementor::elementor_updater Started 
2023-05-23 08:06:45 [info] Elementor/Upgrades - _on_each_version Start  
2023-05-23 08:06:45 [info] Elementor/Upgrades - _on_each_version Finished 
2023-05-23 08:06:45 [info] Elementor data updater process has been completed. [array (
  'plugin' => 'Elementor',
  'from' => '3.13.2',
  'to' => '3.13.3',
)]
2023-05-23 08:06:50 [info] elementor-pro::elementor_pro_updater Started 
2023-05-23 08:06:50 [info] Elementor Pro/Upgrades - _on_each_version Start  
2023-05-23 08:06:50 [info] Elementor Pro/Upgrades - _on_each_version Finished 
2023-05-23 08:06:50 [info] Elementor data updater process has been completed. [array (
  'plugin' => 'Elementor Pro',
  'from' => '3.13.1',
  'to' => '3.13.2',
)]
2023-05-28 21:11:49 [info] Elementor data updater process has been queued. [array (
  'plugin' => 'Elementor',
  'from' => '3.13.3',
  'to' => '3.13.4',
)]
2023-05-28 21:11:50 [info] elementor::elementor_updater Started 
2023-05-28 21:11:50 [info] Elementor/Upgrades - _on_each_version Start  
2023-05-28 21:11:50 [info] Elementor/Upgrades - _on_each_version Finished 
2023-05-28 21:11:50 [info] Elementor data updater process has been completed. [array (
  'plugin' => 'Elementor',
  'from' => '3.13.3',
  'to' => '3.13.4',
)]
2023-05-28 21:11:51 [info] Elementor data updater process has been queued. [array (
  'plugin' => 'Elementor',
  'from' => '3.13.3',
  'to' => '3.13.4',
)]

PHP: showing 5 of 5PHP: 2023-05-12 10:31:45 [warning X 8][/ebs2/vhosts/datatelcom.com/datatelcom.com/wp-content/plugins/elementor-pro/core/utils.php::373] Undefined array key "name" [array (
  'trace' => '
#0: Elementor\Core\Logger\Manager -> shutdown()
',
)]
PHP: 2023-05-15 08:13:36 [warning X 193][/ebs2/vhosts/datatelcom.com/datatelcom.com/wp-content/plugins/elementor/includes/managers/image.php::108] Trying to access array offset on value of type bool [array (
  'trace' => '
#0: Elementor\Core\Logger\Manager -> shutdown()
',
)]
PHP: 2023-05-31 08:57:47 [warning X 1][/ebs2/vhosts/datatelcom.com/datatelcom.com/wp-content/plugins/elementor/modules/history/revisions-manager.php::363] Trying to access array offset on value of type null [array (
  'trace' => '
#0: Elementor\Core\Logger\Manager -> shutdown()
',
)]
PHP: 2023-06-01 08:40:13 [warning X 3][/ebs2/vhosts/datatelcom.com/datatelcom.com/wp-content/plugins/elementor/app/modules/import-export/module.php::717] Attempt to read property "label" on null [array (
  'trace' => '
#0: Elementor\Core\Logger\Manager -> shutdown()
',
)]
PHP: 2023-06-01 08:40:16 [warning X 3][/ebs2/vhosts/datatelcom.com/datatelcom.com/wp-content/plugins/elementor/core/common/modules/ajax/module.php::175] Undefined array key "data" [array (
  'trace' => '
#0: Elementor\Core\Logger\Manager -> shutdown()
',
)]

JS: showing 5 of 5JS: 2023-05-15 17:43:38 [error X 1][<em><u>hidden link</u></em> line 2 > Function:23:9] settings.bg_image is null 
JS: 2023-05-19 20:24:11 [error X 1][<em><u>hidden link</u></em>; elementor.documents.getCurrent() is null 
JS: 2023-05-23 13:27:30 [error X 1][<em><u>hidden link</u></em>; C is undefined 
JS: 2023-05-23 13:28:16 [error X 1][<em><u>hidden link</u></em>; this.view.container is undefined 
JS: 2023-05-29 19:38:43 [error X 4][<em><u>hidden link</u></em>; this.store.find(...) is undefined 



== Elementor - Compatibility Tag ==
	
	Elementor Pro: Compatible
	JetBlocks For Elementor: Incompatible
	JetElements For Elementor: Incompatible
	JetTabs For Elementor: Incompatible
	Polylang Connect for Elementor: Incompatible

== Elementor Pro - Compatibility Tag ==
	
	JetBlocks For Elementor: Incompatible
	JetElements For Elementor: Incompatible
	JetTabs For Elementor: Incompatible
	Polylang Connect for Elementor: Incompatible
June 7, 2023 at 5:59 pm #13788551

marcD-48

3rd attempt at migrating. been running for over 3hrs now. Still bloked at

Migration started, please don't close this window...
Moving your language settings...
Language settings has been migrated
Setting languages for posts...

Followed migration instructions to the letter

June 8, 2023 at 11:05 am #13792351

Dražen
Supporter

Languages: English (English )

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

Hello,

Please enable error logging that will save all errors in a file called debug.log, log file inside the /wp-content/ directory.

To do so, please add the following

define('WP_DEBUG', true);
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false);

Once you have added those lines to your wp-config.php file, please try and replicate the issue. Then go to your installation's wp-content folder and find the "debug.log" file that should've appeared by now (it will appear if it encounters an error in your server).

Then, upload that file into a storage platform of your choosing (Google Drive, Dropbox, etc) and send me the link (make sure it's set as "public" otherwise i won't be able to access its content) so we can download it and take a look at it, and determine where to go from there.

Regards,
Drazen

June 8, 2023 at 12:58 pm #13793273

marcD-48

Hello Drazen,

Thank-you for your reply. You can find the debug.log file on hidden link.

Cheers,

Marc

June 9, 2023 at 4:03 am #13796525

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi Marc,

Checking the debug log, I see there is a fatal error that might cause the issue when migrating data on your site

[08-Jun-2023 12:44:56 UTC] PHP Fatal error: Uncaught Error: Call to undefined function pll_home_url() in /ebs2/vhosts/datatelcom.com/datatelcom.com/wp-content/themes/hello-theme-child-master/functions.php:33

It relates to the child theme, please switch to the main theme or a WordPress standard theme and do migration again to see if it helps.

Look forward to your reply.
Thanks

June 9, 2023 at 12:53 pm #13799685

marcD-48

Hello Long,

I had noticed that line in the debug log and switched to the Hello Theme. Same exact problem. I just tried with the Twenty twenty-three theme and again, same thing.

Only difference (with both the Hello and WP theme) is, this time it is the following fatal error

[09-Jun-2023 12:27:56 UTC] PHP Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /ebs2/vhosts/datatelcom.com/datatelcom.com/wp-content/plugins/migrate-polylang-to-wpml-0.4/classes/class-mpw_migrate_posts.php:89
Stack trace:
#0 /ebs2/vhosts/datatelcom.com/datatelcom.com/wp-content/plugins/migrate-polylang-to-wpml-0.4/classes/class-mpw_migrate_posts.php(24): mpw_migrate_posts->set_original_post_language_details()
#1 /ebs2/vhosts/datatelcom.com/datatelcom.com/wp-content/plugins/migrate-polylang-to-wpml-0.4/migrate-polylang-to-wpml.php(295): mpw_migrate_posts->migrate_posts()
#2 /ebs2/vhosts/datatelcom.com/datatelcom.com/wp-includes/class-wp-hook.php(308): Migrate_Polylang_To_WPML->ajax_migrate_posts()
#3 /ebs2/vhosts/datatelcom.com/datatelcom.com/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()
#4 /ebs2/vhosts/datatelcom.com/datatelcom.com/wp-includes/plugin.php(517): WP_Hook->do_action()
#5 /ebs2/vhosts/datatelcom.com/datatelcom.com/wp-admin/admin-ajax.php(188): do_action()
#6 {main}
thrown in /ebs2/vhosts/datatelcom.com/datatelcom.com/wp-content/plugins/migrate-polylang-to-wpml-0.4/classes/class-mpw_migrate_posts.php on line 89

You can find the latest debug log at hidden link

Hope you can figure out what the problem is as I'd really like to be able to migrate everything over to WPML so I can take advantage of it's compatibility with JetEngine and Rank Math Pro.

For now, I will be restoring from my backup in order to be able to keep on migrating my pages to the new Elementor container format.

Cheers,

Marc

June 9, 2023 at 1:10 pm #13799729

marcD-48

Just a thought here , although I'm guessing it just might be easier said than done but...

Since everything on my site has already been translated using Polylang, if there was a way, to install WPML and link everything together (including all media files) similar to what Polylang does (i.e.: by clicking the + sign and keying in the corresponding name of the page, post, media titkle, etc...) instead of going through the Migration plugin, that would make things a lot easier.

As far as the string translations, at the moment, I only have 3 pages, of which, only about 10% need to be translated since the rest are all WP and Rank Math variables. I can do that myself quickly enough.

Like I said, it's just a thought but, if it can be done 😉

Cheers,

Marc

June 12, 2023 at 3:06 am #13806091

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

I understand the issue, it happens when migrating data from Polylang to WPML with PHP 8.0 or later. Please follow the workaround below to fix this issue and let me know how it goes.

- Edit the file: /wp-content/plugins/migrate-polylang-to-wpml-0.4/classes/class-mpw_migrate_posts.php in your WordPress directory.

- Find the following code:

list($trid, $post_type) = $this->set_original_post_language_details($relation, $default_language_code);

replace it with this one:

if( !is_array( $relation ) ) {
    continue;
}

list($trid, $post_type) = $this->set_original_post_language_details($relation, $default_language_code);

if (count($relation) == 1) {
 continue;
}

- Find the following code:

$original_post_id = isset($relation['sync']) ? $relation['sync'][$default_language_code['polylang']] : $relation[$default_language_code['polylang']];

replace it with this one:

$original_post_id = (isset($relation['sync']) ? $relation['sync'][$default_language_code['polylang']] : isset($relation[$default_language_code['polylang']])) ? $relation[$default_language_code['polylang']] : reset($relation);

if ($original_post_id === NULL ) {
 $original_post_id = reset ($relation);
}

- Save the file and rerun the import.

❌ IMPORTANT: Please backup your database and website before proceeding ❌

Refer to two tickets:
https://wpml.org/forums/topic/problem-with-migrate-from-polylang/#post-12255319
https://wpml.org/forums/topic/migrate-from-polylang-to-wpml-class-mpw_migrate_posts-php-on-line-89/#post-13302781

Look forward to your reply.
Thanks

June 12, 2023 at 2:39 pm #13810695

marcD-48

Well migration has completed BUT, when going to the French portion of my site (ex: hidden link), I get a critical error. FYI, I added the 301 redirect WPML suggested to my .htaccess file.

Also, when I go into the WP media section, no translations appear. HOWEVER, when I go to WPML/Media translation, they are all there. Problem is, some images show up in the primary language when they should be in the secondary (i.e.: some have French graphical text and under Polylang had no translations assigned to them and vice versa for some English images). Is there a way to change that or those can simply be ignored?

If you'd like to see for yourself, give me an email address at which I can send you a temporary login with administrator link.

I'll be going through everything and use your tutorial videos but, as far as I can tell, a substential mount of work needs to me done here to get my site back to the way it was when using Polylang.

June 12, 2023 at 5:05 pm #13811875

marcD-48

FYI, removed RedirectMatch 301 /en/$ hidden link from .htaccess file as it was giving me a 502 error (bad gateway) when updating my pages, posts and custom posts. Can now update but, site still not working as it did before with Polylang installed

June 12, 2023 at 9:05 pm #13812579

marcD-48

Redid migration from scratch, edited class-mpw_migrate_posts.php and changed lines as suggested, edited .htaccess file and re-inserted line RedirectMatch 301 /en/$ hidden link and, "pretty much" everything "appears" to be working at 95% now.

What I find strange right now is from one page to the other, the language switches varies. on some pages, it displays only the secondary language and on others it displays both languages?!?!

Ex: hidden link [display both languages]
WHEREAS
hidden link [only displays the secondary languages]

From what I can tell so far, this only happens on the primary language pages

June 13, 2023 at 3:39 am #13813337

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

I see that issue on your site. I would like to request temporary access (wp-admin and FTP) to your site to take a better look at the issue. Your next reply is set to private to share the info.

❌ IMPORTANT: Please backup your database and website before proceeding ❌
You can use this plugin to create the backup: 
https://wordpress.org/plugins/duplicator/
✙ I would need your permission to de-activate and re-activate Plugins and the Theme and to change configurations on the site if needed. This is also a reason the backup is critical.

Look forward to your reply.
Thanks

June 14, 2023 at 2:00 am #13821043

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

After I login to your site and check the issue again, I do not see both languages in the switcher. So I think it is a caching issue. I try to clear caches: browser, WP Fastest Cache plugin and now, the language switcher works correctly on the frontend. Please check this screenshot hidden link

Can you please recheck this issue on your end?

Look forward to your reply.
Thanks

June 14, 2023 at 12:29 pm #13825067

marcD-48

Good day,

As you said. everything now works. Very strange as I had cleared the cache multiple times!?!

Thank-you for the assist.

Cheers,

Marc

June 15, 2023 at 1:18 am #13828787

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

Glad to hear it works on your end. If you see the main issue of this ticket with migration from Polylang to WPML is resolved, please mark it as Resolved.

Thanks and have a good day.