Skip Navigation

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.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 13:00 9:00 – 13:00 9:00 – 13:00 8:00 – 12:00 8:00 – 12:00 -
- 14:00 – 17:00 14:00 – 18:00 14:00 – 18:00 13:00 – 17:00 13:00 – 17:00 -

Supporter timezone: Europe/Zagreb (GMT+02:00)

This topic contains 6 replies, has 2 voices.

Last updated by Bruno Kos 2 years, 9 months ago.

Assisted by: Bruno Kos.

Author Posts
August 25, 2022 at 9:15 pm #11932457

netzstrategen

I am trying to: Have a fast website. Serve cached pages without database queries.

Link to a page where the issue can be seen: All pages on hidden link

I expected to see: No database queries after warming object cache.

Instead, I got:

- 231 cache misses, followed by
- 199 cache sets in WPML_URL_Cached_Converter->convert_url(), due to
- 1 invocation of WPML_WPSEO_Redirection::clear_converter_cache_for_home_url()

Stack Trace:

WPML_WP_Cache->flush_group_cache()
wp-content/plugins/sitepress-multilingual-cms/classes/utilities/class-wpml-wp-cache.php:71
WPML_WPSEO_Redirection::clear_converter_cache_for_home_url()
wp-content/plugins/wp-seo-multilingual/classes/class-wpml-wpseo-redirection.php:49
WPML_WPSEO_Redirection->is_redirection()
wp-content/plugins/wp-seo-multilingual/classes/class-wpml-wpseo-redirection.php:28

Apparently the invocation of clear_converter_cache_for_home_url() is hardcoded into WPML_WPSEO_Redirection->is_redirection(), but this is invoked on every page request!

The invocation is commented with the following in your code:

	// The unfiltered URL got cached so we need to flush the group.
	self::clear_converter_cache_for_home_url();

It is not clear what this is referring to. The function is not filtering or converting any URLs afterwards. There does not seem to be a point in clearing the cache.

Proposed solution: Remove the hardcoded invocation without replacement.

Thanks,
Daniel Kudwien
hidden link
hidden link

August 26, 2022 at 11:42 am #11937091

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

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

Hi,

I asked our 2nd tier team about this, I'll get back to you as soon as I have any news or questions for you.

Regards,
Bruno Kos

August 29, 2022 at 7:51 am #11946817

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

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

Hi,

According to our 2nd tier (see this function):

add_filter( 'wpml_skip_convert_url_string', '__return_true' );
            $base_url_path = ltrim( wp_parse_url( home_url(), PHP_URL_PATH ), '/' );
            remove_filter( 'wpml_skip_convert_url_string', '__return_true' );
 
            // The unfiltered URL got cached so we need to flush the group.
            self::clear_converter_cache_for_home_url();

We called home_url() after adding a filter “wpml_skip_convert_url_string” so the unfiltered URL is cached we are clearing the wrong cached URL so the filtered URL can be used on next home_url call.

Does it help clarifying this?

Regards,
Bruno Kos

August 29, 2022 at 1:49 pm #11950095

netzstrategen

Thanks for the answer.

The use-case was addressed in WPML already. WPML caches the convert_url result separately depending on the chosen "strategy". When `wpml_skip_convert_url_string` is enabled, then a different strategy is applied and thus the result is cached for these invocation parameters only. For that reason, the clearing of the whole cache is obsolete.

In any case – you cannot flush the whole cache of converted URLs. That has terrible ramifications for the performance of all websites using WPML.

Can you remove the cache clearing from the code?

We're doing performance optimizations for various WordPress websites. WPML is standing out as the only plugin that does not behave correctly. Next to the issue mentioned here, WPML is also caching data in custom ways are not meant to be used for cached data (transients and even options) and thus break every standard object cache setup. We will create separate threads for those issues when time permits.

August 30, 2022 at 2:26 pm #11958413

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

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

Hi,

Our 2nd tier is doing some tests with this, we will update here as soon as we have some info.

Regards,
Bruno Kos

August 31, 2022 at 1:56 pm #11965447

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

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

Hi,

Thank you for going so far in investigating this - this is escalated to our 2nd tier team and may take some debugging time, I'll get back to you as soon as I have any news or questions for you!

Regards,
Bruno Kos

September 1, 2022 at 6:15 am #11968607

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

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

Hi,

This issue has been escalated to WPML developers.

I will keep this thread updated as soon as I get any new information from them!

Regards,
Bruno Kos