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

Clear CPT custom cache files correctly #7277

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

wordpressfan
Copy link
Contributor

@wordpressfan wordpressfan commented Feb 6, 2025

Description

Fixes #4508

This PR makes sure that we remove all custom cache files for custom post types are deleted properly.

Type of change

  • Bug fix (non-breaking change which fixes an issue).

Detailed scenario

When we clear custom post type post (with any clearance action like editing the post), we should clear the archive page (shop page for woocommerce product CPT as an example), but when we have webp enabled (or any feature that creates custom cache file other than index.html or index.html_gzip) those custom cache files are kept there without being removed.

Technical description

Documentation

We just add the url (the whole folder) to the folders to be deleted.

New dependencies

N/A

Risks

I need to take from the expertise of @remyperona because he knows this part more than anyone else, do u think this may cause any issue for removing wrong cache files or so?

Mandatory Checklist

Code validation

  • I validated all the Acceptance Criteria. If possible, provide screenshots or videos.
  • I triggered all changed lines of code at least once without new errors/warnings/notices.
  • I implemented built-in tests to cover the new/changed code.

Code style

  • I wrote a self-explanatory code about what it does.
  • I protected entry points against unexpected inputs.
  • I did not introduce unnecessary complexity.
  • Output messages (errors, notices, logs) are explicit enough for users to understand the issue and are actionnable.

Unticked items justification

All good.

Additional Checks

  • In the case of complex code, I wrote comments to explain it.
  • When possible, I prepared ways to observe the implemented system (logs, data, etc.).
  • I added error handling logic when using functions that could throw errors (HTTP/API request, filesystem, etc.)

@wordpressfan wordpressfan self-assigned this Feb 6, 2025
@wordpressfan wordpressfan marked this pull request as ready for review February 6, 2025 00:28
Copy link

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for 5fb67a81 100.00% (target: 50.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (5fb67a8) Report Missing Report Missing Report Missing
Head commit (b061cd9) 38788 17158 44.24%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#7277) 1 1 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

@wordpressfan wordpressfan requested a review from a team February 6, 2025 00:36
@Mai-Saad
Copy link
Contributor

Mai-Saad commented Feb 7, 2025

@wordpressfan Thanks for the PR. please note that we have the following regression
1- product permalink is shop base
2- cache shop , product 1, product 2
3- edit product 1 or clear cache of product 1 from page edit
4- all shop folder is deleted including product 2 cache ==> on trunk product 2 isnot touched

@remyperona
Copy link
Contributor

If you do it that way, you're going to delete cache of any child item in the permalink structure, that's why the deletion is not using the base but the filenames.

You need a different approach to handle the different cache files variations. Possibly with RegEx if it's usable (I don't remember right now), you could do something like index(.*).html.

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.

Partial purge does not clear CPT archive when non-default cache files are used
4 participants