Skip to content

Fix woocommerce object cache#1495

Open
Komarovski wants to merge 3 commits into
qtranslate:masterfrom
Komarovski:fix-woocommerce-object-cache
Open

Fix woocommerce object cache#1495
Komarovski wants to merge 3 commits into
qtranslate:masterfrom
Komarovski:fix-woocommerce-object-cache

Conversation

@Komarovski

Copy link
Copy Markdown
Contributor

Description

Fixes WooCommerce attribute labels and values being displayed in the language of the first request when a persistent object cache is enabled.

WooCommerce cache keys for attribute taxonomies and product terms do not include the current qTranslate-XT language. As a result, translated data may be stored and reused for other languages.

Changes

  • Exclude the woocommerce-attributes group from persistent object caching.
  • Translate product terms after WooCommerce retrieves them from cache.
  • Reapply the requested language to term objects that already contain i18n_config.

Testing

Tested with WooCommerce and LiteSpeed Object Cache using Memcached.

Verified that product attribute labels and term values switch correctly between Russian and Ukrainian after clearing and rebuilding the object cache.

Apply the requested language even when a term already contains i18n_config.

Persistent object caches may return term objects translated during an earlier request. Previously, name and description were translated only when i18n_config was first created, causing the first cached language to be reused.
Exclude the WooCommerce attributes cache group from persistent storage.

WooCommerce caches the filtered attribute taxonomy data after qTranslate-XT has translated it. Since the cache key does not contain the current language, persistent object caches may serve attribute labels in the language of the first request.
Translate product attribute terms after WooCommerce retrieves them from its cache.

WooCommerce product-term cache keys do not include the current language, so persistent object caches may return attribute values translated during an earlier request in another language.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant