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

Only apply performance hints optimizations when page html is not empty #7298

Merged

Conversation

wordpressfan
Copy link
Contributor

@wordpressfan wordpressfan commented Feb 10, 2025

Description

When visiting a taxonomy page (category page) with a wrong url, we reset the buffer to return empty HTML but then we apply the beacon script to this empty HTML which causes the page to load as an empty page instead of returning empty string which will show the unoptimized page in that case.

Type of change

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

Detailed scenario

Steps to reproduce the first issue:

  1. Get any category url, let's say it's http://wprocket.localhost/category/uncategorized/
  2. Change the catrgory url to be http://wprocket.localhost/category/anythinghere/uncategorized/
  3. You will see a blank page but we expect to see the correct page without any optimizations and not caching this page.

Steps to reproduce the second issue:

  1. Install/activate custom permalinks plugin.
  2. Edit any category in dashbord.
  3. Update its permalink to be one word.
  4. Clear priority elements.
  5. Visit this category frontend.
  6. You will see blank page.

Technical description

Documentation

Here we added a bailout check to make sure that we have a valid HTML before adding the script into it.

New dependencies

N/A

Risks

N/A

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

Will check the automation tests.

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.)

Copy link

codacy-production bot commented Feb 10, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for a9a0f961 80.00% (target: 50.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (a9a0f96) Report Missing Report Missing Report Missing
Head commit (18b8842) 38790 17159 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 (#7298) 5 4 80.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.

@piotrbak piotrbak added this to the 3.18.1.5 milestone Feb 10, 2025
@wordpressfan wordpressfan self-assigned this Feb 10, 2025
@wordpressfan wordpressfan marked this pull request as ready for review February 10, 2025 18:36
@wordpressfan wordpressfan requested a review from a team February 10, 2025 18:37
@Khadreal Khadreal changed the base branch from develop to trunk February 11, 2025 11:48
@Khadreal Khadreal force-pushed the fix/add-the-beacon-only-when-the-page-html-is-not-empty branch from afb303a to e9ef9b6 Compare February 11, 2025 12:23
@Khadreal Khadreal force-pushed the fix/add-the-beacon-only-when-the-page-html-is-not-empty branch from 63280e1 to 3f940f9 Compare February 11, 2025 12:42
@Khadreal Khadreal merged commit 80eb913 into trunk Feb 11, 2025
13 checks passed
@Khadreal Khadreal deleted the fix/add-the-beacon-only-when-the-page-html-is-not-empty branch February 11, 2025 12:59
Khadreal added a commit that referenced this pull request Feb 12, 2025
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.

3 participants