Skip to content Skip to sidebar

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

Problem:
The client encountered a bug with WPML where the automatic redirection to the correct language page for custom post type terms was not functioning. The error 'Call to a member function wp_safe_redirect() on null' was identified in 'sitepress-multilingual-cms/classes/query-filtering/class-wpml-query-parser.php' on line 340.

Solution:
We recommend the following troubleshooting steps:
1. Ensure you have a full backup of your website and database.
2. Update WordPress to the latest version.
3. Increase the 'WP Memory Limit' to at least 128MB, preferably 256MB. You can do this by adding the following code to your wp-config.php file:

define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' );

Make sure to add these lines before the 'Happy publishing' comment.
4. Switch to a standard WordPress theme like 2021 or 2023 to ensure the issue is not theme-related.
5. Deactivate all plugins except WPML and its addons to check if the issue persists.
6. Reactivate each plugin one by one, checking for the issue after each activation to identify any conflicts.

If these steps do not resolve the 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 3 replies, has 2 voices.

Last updated by Waqas Bin Hasan 1 year, 7 months ago.

Assisted by: Waqas Bin Hasan.

Author Posts
December 11, 2023 at 7:47 am #15033333

lukasS-6

I found a bug in WPML. Normally if you enter the slug of one language and prepend the wrong language folder, WPML will automatically fix it and redirect to the correct page. This is not working for custom post type terms.

Example with normal pages, where it is working as expected:
Page with German (/de/test-de) and Italian (/it/test-it). If you navigate to /de/test-it or /it/test-de, WPML will automatically redirect to the correct page.

The issue is in "sitepress-multilingual-cms/classes/query-filtering/class-wpml-query-parser.php"

Exception "Call to a member function wp_safe_redirect() on null" (line 340)

We only have the issue for taxonomies (e.g. custom post type "Stories" with taxonomy "category")

December 11, 2023 at 8:06 am #15033435

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

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

Hi,

Reference to our recent chat, please let me know your findings once that's done.

Also provide the debug information of your website for an overview of your setup. See https://wpml.org/faq/provide-debug-information-faster-support/ for more information.

I've enabled the debug information section for your next reply.

Additionally you can also take a look at https://wpml.org/faq/checklist-before-opening-a-ticket-in-wpml-support/ and cross-check for a few initial fixes.

See https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/ for details on privacy and security.

Regards.

December 12, 2023 at 8:42 am #15043097

lukasS-6

Hi,

link scan didn't fix the issue. Still the same exception ("Call to a member function wp_safe_redirect() on null" in "sitepress-multilingual-cms/classes/query-filtering/class-wpml-query-parser.php" line 340

Let me know if I should try changing some other settings.

Regards

December 12, 2023 at 12:41 pm #15046005

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

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

Thank you for the updates and the debug information.

I see a few things need fixing before continuing further. Please try the following:

IMPORTANT: Take full backup of your website and database beforehand. It is highly advised to try the following on a staging/dev site first, so your live website isn't compromised.

- Update WordPress to the latest version.
- Fix “WP Memory Limit” to at least 128MB while 256MB is recommended. See https://wpml.org/home/minimum-requirements/ for detailed information. You can set this in your wp-config.php file by adding following code:

define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' );

Remember to add these lines before the line where it says:
/* That's all, stop editing! Happy publishing. */

And check for the issue. If it still happens, then please continue with the following:

- Switch to a standard WordPress theme like 2021 or 2023. Because your current theme isn't on our compatibility list (https://wpml.org/theme/) so we can be sure if problem isn't coming from there.
- Deactivate all plugins except WPML and its addons and check for the issue.
- Activate each plugin one-by-one, while keeping check on the issue after a plugin is activated. This way you'll be able to pinpoint a plugin having a conflict (or problem), if any.

Please let me know and I'll try my best to help you further on the matter.

Regards.

December 13, 2023 at 8:40 am #15051755

lukasS-6

Hi,

thanks a lot for your help. After testing the issue in an empty WP installation + only WPML installed I found out that it works there.
The issue therefore was with our specific WP setup.

Thanks again for your help.