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.

This topic contains 9 replies, has 2 voices.

Last updated by Bruno Kos 2 months, 1 week ago.

Assigned support staff: Bruno Kos.

Author Posts
June 28, 2019 at 10:38 am #4106607

rogerL-4

Hello,

We have a live site with a problem that causes the shop pages on some languages to randomly stop displaying products.

There's plenty of people with the same problem on the forums and we've tried all the solutions we could find (recreating pages, updating, etc...)

After some debugging we found that the problem in our case is that the permalinks for the base language get lost/reset for unknown reasons after a while (sometimes weeks, sometimes every other day).

Entering the admin and saving the permalinks resolves the problem every time.
We know it’s a permalink problem because we have installed Rewrite rules inspector and shows some missing rules when the shop page is broken (attached screenshoot).

Doing some basic testing this seems to happen when a rewrite rules flush is triggered while not on the base language WPML has configured. You can trigger it from admin using the plugin mentioned above to trigger the bug.

To make sure this was not something on our end we made a clean install to try to reproduce this behaviour with the following:
- Wordpress 5.2.2
- Classic editor 1.5
- Rewrite rules inspector 1.2.1
- Woocommerce 3.6.4
- Woocommerce Multilingual 4.6.3
- WPML 4.2.6
- WPML String translation 2.10.4
- WPML translation management 2.8.5
- Storefront Theme: 2.5.0

We setup everything in this order:
- Base wordpress config
- Woocommerce setup
- Woocommerce storefront setup + product import
- Wpml Setup
- Basic translations and multilang config

WPML was configured as follows:
- 4 Languages: en, es, ca, pt-pt. The base language is en.
- Language as folder

Then we set the urls and routes as follow:
Base shop pages:
• En: /shop
• Es: /tienda
• Ca: /tenda
• Pt: /shop

Url product_cat tax:
• En: /shop
• Es: /tienda
• Ca: /tenda
• Pt: /shop

Url product_tax:
• En: /shop/tag
• Es: /tienda/etiqueta
• Ca: /tenda/etiqueta
• Pt: /shop/tag

With this install and doing the rules flush as mentioned above we get the bug every time so it’s not really a problem only specific to our site.

We also tried changing the portuguese slug to shop2 to test if having the same slug on 2 of the pages caused the problem but it doesn't fix anything.

We tried updating the plugins to the latest version ad well but that didn't help either.

We're not 100% sure this is what is causing the problems on our live site since they happen radomly but everything points to this direction.

We'll do some research to try and find what can trigger a rewrite rule flush there, but shouldn't this behaviour be considered a bug within WPML?

Thanks,
Roger

June 28, 2019 at 12:51 pm #4107471

Bruno Kos
Supporter

Languages: English (English )

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

Hi,

Thank you for contacting WPML support!

Can you tell me if the issue you're having is the same as any of the examples?
https://wpml.org/forums/topic/few-times-a-day-products-on-shop-page-dissappear/
https://wpml.org/forums/topic/shop-page-in-default-language-randomly-disappears/

As for this:

We'll do some research to try and find what can trigger a rewrite rule flush there,

It would be great if you could find anything which triggers this, because so far we were not able to find what is behind this, whether this is server issue, caching issue, WPML bug or something else. None of the clients were able to provide clear steps on what causes this, because it happens randomly in probably all the cases we had, causing us additional headaches while trying to determine what causes it and possibly fix it.

but shouldn't this behaviour be considered a bug within WPML?

It is definitely possible that this is a WPML bug - however as outlined above, we were not able to get this resolved yet because we do not know what triggers it. And without having an exact way to reproduce this issue, we cannot trace it and therefore fix it. That's also the reason why we are unable to provide any meaningful workaround for our clients.

It seems that some of our clients ( see the first link) have tried creating cron jobs that refresh permalinks periodically.

There is some information here that might help:
https://wpml.org/errata/htaccess-is-rewritten-with-language-folder/

In any case, I have brought this again to our 2nd tier who handles this case and they are examining this more thoroughly again.

I will keep this thread updated as soon as I get some additional insight into this.

Regards,
Bruno Kos

July 1, 2019 at 10:03 am #4117681

rogerL-4

Hello,

Taking a look at those 2 posts it’s definitely the same issue.

Checking the installed plugins, we found these with calls to flush rewrite rules:

4 already mentioned in another of the posts you provided:
• Gravity forms
• Woocommerce
• WPML multilingual
• Yoast SEO

1 not mentioned but it should be harmless since it only calls it when plugin options are messed with.
• Wp-store-locator: Runs flush on admin_init if permalink options are edited and on plugin activation

I’ve altered the core flush_rewrite_rules() function to save to a log the execution trace every time it gets called so next time the bug happens we should be able to pin-point the offender plugin.

As I said you can easily trigger it just by using the rewrite rules inspector plugin from the admin by flushing the rules in another language but I understand that might not be of much help.

I will let you know when I find out more.

Thanks,
Roger

July 1, 2019 at 11:04 am #4118169

Bruno Kos
Supporter

Languages: English (English )

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

Hi,

Thank you for providing new insights - our 2nd and 3nd are discussing this as well - if I get any new information from them, I will post it here immediately.

Regards,
Bruno Kos

July 2, 2019 at 9:53 am #4125441

rogerL-4

Well looks like I’ve already found something 🙂

Saving the non base language of the shop page on the admin inmediatly breaks the rewrites.
WooCommerce itself calls flush_rewrite_rules every time this page is saved breaking the stored rewrite rules.

[19-07-02 09:00:07] - flush_rewrite_rules
#0 /wp-content/plugins/woocommerce/includes/class-wc-post-types.php(577): flush_rewrite_rules()
#1 /wp-includes/class-wp-hook.php(286): WC_Post_Types::flush_rewrite_rules('')
#2 /wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters('', Array)
#3 /wp-includes/plugin.php(465): WP_Hook->do_action(Array)
#4 /wp-content/plugins/woocommerce/includes/wc-core-functions.php(981): do_action('woocommerce_flu...')
#5 /wp-includes/class-wp-hook.php(286): flush_rewrite_rules_on_shop_page_save('')
#6 /wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)
#7 /wp-includes/plugin.php(465): WP_Hook->do_action(Array)
#8 /wp-admin/admin-footer.php(73): do_action('admin_footer', '')
#9 /wp-admin/post.php(350): include('/home/lunabeach...')
#10 {main}

The woocommerce plugin does call flush_rewrite_rules a few times but they all seem to go throught a hook "woocommerce_flush_rewrite_rules" so I think this shouldn't be too hard to fix.

Looking a bit deeper into the code there I’m seeing some of the flush_rewrite_rules get attached to cron calls which might explain the erratic appearance of this bug since I'm not sure how you handle language in that situation and might depend on the current page viewer.

Could you please take a look into this and let me know when we can expect a fix?

Regards,
Roger

July 2, 2019 at 12:48 pm #4127069

Bruno Kos
Supporter

Languages: English (English )

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

Hi Roger,

Thank you for an update - I've also passed all of this information to our 2nd tier. I still haven't heard from them, but hopefully this will bring some new light to this and may help them debug this quicker.

Regards,
Bruno Kos

July 31, 2019 at 3:23 pm #4316019

rogerL-4

Do we have any update on this?

August 1, 2019 at 5:24 am #4318817

Bruno Kos
Supporter

Languages: English (English )

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

Hi,

We are currently waiting for feedback from our WooCommerce multilingual developer, hopefully his insights will help us clear some of the unknowns here.

Regards,
Bruno Kos

August 2, 2019 at 10:21 am #4328893

Bruno Kos
Supporter

Languages: English (English )

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

Hi,

I have some news - we were able to find what is causing this:

"Thanks to user for this info "I have found that if I edit and save the translated shop page /tienda from the backend of the site it seems to trigger the issue in most cases. "

The issue has been escalated to our WCML developers and I will keep you posted on how development goes!

Regards,
Bruno Kos

August 12, 2019 at 5:56 am #4378473

Bruno Kos
Supporter

Languages: English (English )

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

Hi,

The fix for this should go into the next WooCommerce multilingual version (not sure when it will be published, but hopefully soon).

This is how we were able to reproduce this:

- setup WCML + WPML in 2 languages
- translate shop page to second language ( automatically or manually )
- create few dummy products
- visit shop page in both languages and make sure they working fine
- go to admin and update shop page in second language
- got to shop front page in default language
- notice broken page without products

Once the new WooCommerce multilingual is released, you need to just re-save shop page in backend.

Once it becomes available for download, please try and let me know!

Regards,
Bruno Kos