Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yoast breaks rewrite rules daily when using domain-per-language WPML feature #18587

Open
2 tasks done
janis-ps opened this issue Jun 18, 2022 · 0 comments
Open
2 tasks done

Comments

@janis-ps
Copy link

janis-ps commented Jun 18, 2022

  • I've read and understood the contribution guidelines.
  • I've searched for any related issues and avoided creating a duplicate issue.

Please give us a description of what happened.

Client's website randomly stopped showing products on the product archive page. Eventually we found that rewrite_rules are sometimes broken and don't contain post_type=product in the main WP query.

Please describe what you expected to happen and why.

We expected products to not randomly stop showing.

How can we reproduce this behavior?

Assume a WPML language-per-domain setup:

English -> example.eu (default domain)
Latvian -> example.lv
Lithuanian -> example.lt

  1. save permalinks via WP settings (this resets to a known good state)
  2. edit "wpseo" option via DB, change "home_url" value to example.lv (non-default language domain)
  3. invoke "wpseo_permalink_structure_check" cron task via a cron manager
  4. quickly open example.lt (a different non-default language domain)
  5. open product page in the default language domain (example.eu). All products are missing.

Technical info

The problem is caused by the Indexable_HomeUrl_Watcher class, which deletes rewrite_rules option upon detecting that the home URL has changed. WPML domain-per-language feature causes get_home_url() to return a different value for each language.

WordPress will automatically regenerate rewrite_rules from the frontend upon the next visit. If that visit is from a non-default language domain, the generated permalinks will not contain rules for all languages.

At most, Yoast should show a notification that permalinks should be re-saved.

Used versions

  • WordPress version: 6.0
  • Yoast SEO version: 19.1
  • Woocommerce: 6.4.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants