The site migration is now complete and oss-material.ca is properly registered as an independent site. However, the original fatal error still persists even after updating to WPML 4.9.2.
The error occurs when saving or editing an existing translation page in the WordPress editor. WordPress attempts to create a post revision during save, wp_insert_post returns null, and WPML's hook crashes because it expects a WP_Post object.
Full error details:
An error of type E_ERROR was caused in line 55 of the file:
wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/wpml/src/UserInterface/Web/Infrastructure/WordPress/CompositionRoot/Config/Event/Translation/Links/ItemUpdateEvent.php
Error message:
Uncaught TypeError: Argument #2 ($post) must be of type WP_Post, null given, called in wp-includes/class-wp-hook.php on line 343
Stack trace summary:
- edit_post() is called
- wp_update_post() triggers wp_insert_post()
- wp_after_insert_post() fires
- wp_save_post_revision_on_insert() is called
- wp_save_post_revision() → _wp_put_post_revision() → wp_insert_post() returns null
- do_action('save_post', 2572, NULL) is fired with null post
- WPML's ItemUpdateEvent closure receives null instead of WP_Post and crashes
This appears to be a bug in WPML 4.9.2 where the ItemUpdateEvent hook does not handle a null $post argument gracefully. Could you please escalate this as a bug report or provide a fix?
Are you sure that the entire database and all files were migrated correctly?
Would it be possible to perform a test migration to a local environment using an alternative method (e.g., a plugin like Duplicator or All-in-One WP Migration within the fix above) and check whether the issue still occurs?
I’ve also enabled debug information for this support ticket. Please follow this guide to retrieve it from your site and share it
Same setup and content works fine on another server where I copied the content from.
I also migrated the very same web page on another (3rd one for testing purposes) server, and that works fine too.
Also used UpdraftPlus for the test migration.
I suspect this may be related to a server configuration issue or possibly corrupted database entries.
I would need temporary access to your site (wp-admin and FTP)—preferably to a staging or test environment where the issue can be reproduced. When you submit your next reply, you will find the required fields below the comment area. Please note that this information is private and will only be visible to you and me.
Additionally, please provide the exact steps to reproduce the issue, so I can follow the same process on my end.
Let me know if I have your permission to temporarily install the Adminer plugin.
The fatal error sometimes occurs.
I use WordPress editor to create translated versions of the pages.
I do not use translation dashboard since I need to change page content and layout when necessary.
So to create a language version of the related page I click + sign on the right of the page name (ie: please see the attached 001.png as an example to create the Portuguese version of the page).
Then I copy the content from English verison and then change all the text (content) to that language (ie: Portuguese).
After clicking publish, WordPress normally saves. It generally does.
But sometimes I get that fatal error (did not get a screenshot but it says: "There has been a critical error on this website. Please check your site admin email inbox for instructions. If you continue to have problems, please try the support forums. Learn more about troubleshooting WordPress.").
The interesting part is that, the page is saved despite that error.
I'm not sure if there's been a firewall delay just about that saving process and WPML can not communicate with its servers at that exact delay period, or there's a mistake on the database itself. I'm not a code guy, just try to understand and solve the issue.