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

Make sure that we cache only valid posts/pages urls #7236

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

Conversation

wordpressfan
Copy link
Contributor

Description

Fixes https://github.com/wp-media/wp-rocket.me/issues/4456

This PR will make sure that we cache only

Type of change

  • Bug fix (non-breaking change which fixes an issue).
  • Enhancement (non-breaking change which improves an existing functionality).

Detailed scenario

For posts, pages, and even custom posts in some cases when we add any string inside the url, we still cache those pages because they don't return 404 error, here we make sure that those urls are not cached at all.

More details are inside the issue itself.

Technical description

Documentation

We compare the current page/post urls with their correct urls and stop caching for those not valid ones.

New dependencies

No

Risks

We have this code exactly like what we handled taxonomies so I hope we don't have a false cases that we detect the valid urls correctly.

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

Checking tests now.

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 Jan 22, 2025
Copy link

codacy-production bot commented Jan 22, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for 573e2741 56.67% (target: 50.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (573e274) Report Missing Report Missing Report Missing
Head commit (6ba6644) 39098 17147 43.86%

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 (#7236) 30 17 56.67%

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 marked this pull request as ready for review January 23, 2025 12:42
@wordpressfan wordpressfan requested a review from a team January 23, 2025 13:25
@hanna-meda hanna-meda added this to the 3.18.2 milestone Jan 28, 2025
Copy link
Contributor

@hanna-meda hanna-meda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @wordpressfan, for this PR.
Exploratory and Test Plan execution went well.
testrail-report-696.pdf

@piotrbak piotrbak added the needs: documentation Issues which need to create or update a documentation label Feb 17, 2025
@wordpressfan
Copy link
Contributor Author

I think we need to wait a bit before merging this PR because we got some issues with taxonomy pages PR and the solution here is exactly the same.

Those issues are:

  1. When using custom permalink that mentioned as second issue In this PR description
  2. When using custom rewrite rules as mentioned in the last dev escalation with an example here

but now this will happen with posts so I'd suggest having a filter to enable/disable this feature when needed (that's a product decision)

@piotrbak
Copy link
Contributor

CC @MathieuLamiot

In general, we'll need a filter here and some more testing as we know about the new limitations

@piotrbak piotrbak removed this from the 3.18.2 milestone Feb 17, 2025
@MathieuLamiot
Copy link
Contributor

Definitely, let's go with adding a filter around this whole functionality once 3.19-prealpha is released internally 👌

@remyperona
Copy link
Contributor

@wordpressfan I did a refactor and added the filter if you want to have a look

Copy link
Contributor Author

@wordpressfan wordpressfan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't approve my own PR, but seems valid from my side, just two questions.
Thanks Boss.

@MathieuLamiot MathieuLamiot added this to the 3.18.3 milestone Mar 14, 2025
@piotrbak piotrbak modified the milestones: 3.18.3, 3.19 Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: documentation Issues which need to create or update a documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants