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

Partial Preload trying to access incorrect shop page urls (WooCommerce) #2068

Closed
webtrainingwheels opened this issue Oct 24, 2019 · 28 comments · Fixed by #5458
Closed

Partial Preload trying to access incorrect shop page urls (WooCommerce) #2068

webtrainingwheels opened this issue Oct 24, 2019 · 28 comments · Fixed by #5458
Assignees
Labels
effort: [XS] < 1 day of estimated development time module: preload priority: low Issues that can wait severity: minor Defect that does not affect functionality type: bug Indicates an unexpected problem or unintended behavior
Milestone

Comments

@webtrainingwheels
Copy link

webtrainingwheels commented Oct 24, 2019

When you publish a product in WooCommerce or update it, Partial_Preload is trying to access some incorrect URLs for the page set as the Shop page in WooCommerce.

On every product publish/update, these 3 URLs 404:
404s

Steps to reproduce:

  • Activate WooCommerce
  • Go to WooCommerce > Settings > Products: make sure the Shop page has been set (it can be set to any page): https://jmp.sh/8midTHf
  • Make sure preload is active in WP Rocket
  • Update a product
  • Use whichever tool you like to log 404 errors (I used Redirection plugin)
  • Observe that the URLS indicated give a 404: https://jmp.sh/dGHBk7w

Tickets:
https://secure.helpscout.net/conversation/986778716/127894?folderId=377611
https://secure.helpscout.net/conversation/983825572/127434?folderId=377611

@webtrainingwheels
Copy link
Author

@Tabrisrp Is it a duplicate, or related to : #1904 ?

@Tabrisrp
Copy link
Contributor

Is the shop page the archive page for the Products CPT?

@GeekPress
Copy link
Contributor

@webtrainingwheels If you have a chance to remind you the problem, can you reply to @Tabrisrp question? 👆

@webtrainingwheels
Copy link
Author

@Tabrisrp ummmm sorry for the delay! ;) Yes, the shop is the archive page for Products

@camilamadronero-zz
Copy link

@GeekPress
Copy link
Contributor

@webtrainingwheels Thanks for the response.
Will it be possible to update your original post with the Steps to reproduce section?

@webtrainingwheels
Copy link
Author

@GeekPress done

@GeekPress GeekPress added module: preload priority: low Issues that can wait type: bug Indicates an unexpected problem or unintended behavior and removed needs: testing waiting for feedback labels Jun 9, 2020
@alfonso100
Copy link
Contributor

@webtrainingwheels
Copy link
Author

Similar case: https://secure.helpscout.net/conversation/1320995121/205970?folderId=377611
In this case it's the archive page for a different CPT, not the Shop one.

Similar to Alfonso's case above, Preload is trying to directly access:
index-httpspage (???)
index-https.html_gzip
index-https.html

@vmanthos
Copy link
Contributor

Similar to Alfonso's case above, Preload is trying to directly access: index-httpspage (???)

When rocket_clean_post() runs we are gathering related posts to clean their cache. That's being done with rocket_get_purge_urls().

This seems like it could be coming from here:

$purge_urls[] = $post_type_archive . $filename . $GLOBALS['wp_rewrite']->pagination_base;

@NataliaDrause
Copy link
Contributor

@vmanthos
Copy link
Contributor

vmanthos commented Jan 15, 2021

This is happening because of what I mentioned in my previous comment on this thread.

We are adding the $filename here, which we shouldn't be doing:

$purge_urls[] = $post_type_archive . $filename . $GLOBALS['wp_rewrite']->pagination_base;

Note:
We should investigate if the resulting URL should include a trailing slash or not.

Slack Conversation: https://wp-media.slack.com/archives/C43T1AYMQ/p1610721622025900

Related ticket: https://secure.helpscout.net/conversation/1393456557/230505

@NataliaDrause
Copy link
Contributor

@piotrbak piotrbak added the severity: minor Defect that does not affect functionality label Mar 11, 2021
@webtrainingwheels
Copy link
Author

@NataliaDrause
Copy link
Contributor

@DahmaniAdame
Copy link
Contributor

@webtrainingwheels
Copy link
Author

@CrochetFeve0251 CrochetFeve0251 added GROOMING IN PROGRESS Use this label when the issue is currently being groomed. needs: grooming and removed needs: grooming GROOMING IN PROGRESS Use this label when the issue is currently being groomed. labels Sep 9, 2022
@piotrbak piotrbak added this to the 3.12.2 milestone Sep 11, 2022
@piotrbak
Copy link
Contributor

As an update for this specific case and the new Preload:

  1. Warning in the logs is not present
  2. We're clearing the cache of shop (archive for WooCommerce products) correctly
  3. We're not changing the status of shop in the database
  4. We're adding the unnecessary entries (shop/index-https.html shop/index-https.html_gzip shop-7/index-httpspage) to the database and setting their status to pending
    20682

@CrochetFeve0251
Copy link
Contributor

CrochetFeve0251 commented Sep 21, 2022

Reproduce the problem

The problem was easy to reproduce.

Identify the root cause

The root cause of the problem is coming from the clearing cache logic.
As we don't want it to clean recursively every files inside the shop folder, we have to precise files.
However at the level of the preload we are saving urls given directly.

Scope a solution

A quick solution would be to remove index.html or index.html_gzip from url we add to preload.

For that we can create a new filter rocket_preload_format_url before adding the url to the database in create_or_update and create_or_nothing.

Then we will create a method format_preload_url on the Preload subscriber with the following logic:

public function format_preload_url( string $url ) {
 return preg_replace('/(index\.html)|(index\.html_gzip)$/', '', $url);
}

Finally we will hook that function to the filter rocket_preload_format_url.

Estimate the effort

Effort XS

@CrochetFeve0251 CrochetFeve0251 self-assigned this Sep 21, 2022
@CrochetFeve0251 CrochetFeve0251 added the effort: [XS] < 1 day of estimated development time label Sep 21, 2022
@NataliaDrause
Copy link
Contributor

Related: https://secure.helpscout.net/conversation/2032139861/373700?folderId=3864740

These URLs are being preloaded:

https://www.profesenapuros.com/tienda/index-httpspage/
https://www.profesenapuros.com/tienda/index-https.html_gzip/
https://www.profesenapuros.com/tienda/index-https.html/

@piotrbak piotrbak modified the milestones: 3.12.2, 3.12.3 Oct 12, 2022
@alfonso100
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort: [XS] < 1 day of estimated development time module: preload priority: low Issues that can wait severity: minor Defect that does not affect functionality type: bug Indicates an unexpected problem or unintended behavior
Projects
None yet