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

Super Cache: fix how the plugin uses apache_request_headers #39951

Merged
merged 5 commits into from
Dec 19, 2024

Conversation

donnchawp
Copy link
Contributor

If a site has disabled the function apache_request_headers() then WPSC will not display the "Rejected User Agents" textarea on the settings page. It would also cause a fatal error because the code checked if the function existed, before creating a fallback of the same name.

Proposed changes:

  • Create a function wpsc_apache_request_headers() that is a fallback for that function, and it checks if the original function exists and is callable before calling it. Otherwise, it extracts the headers.
  • Remove the apache_request_headers() checks that were added 6 years ago to hide the Rejected User Agent settings.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Does this pull request change what data or activity we track or use?

Testing instructions:

  • If you're using the Jetpack Docker container, login to it with jetpack docker sh
  • Edit the php.ini of your server. If the above container, it'll be /etc/php/8.2/fpm/php.ini
  • Look for "disable_functions =" and add apache_request_headers at the end.
  • Restart PHP with service php8.2-fpm restart
  • Go to the WPSC settings, and enable "304 Browser caching".
  • Enable debugging in the plugin and watch the logs in a new browser tab.
  • Open a new private window and load the front page of your site.
  • You should see a log entry: "304 browser caching not possible as timestamps differ"
  • Reload the page, and you may see this: "Send 304 Not Modified header."
  • You could also error_log $remote_mod_time in wp-cache-phase2.php on line 289 and line 293 to make sure they match.
  • Don't forget to reverse changes to php.ini and restart PHP.

@donnchawp donnchawp added [Type] Bug When a feature is broken and / or not performing as intended [Plugin] Super Cache A fast caching plugin for WordPress. labels Oct 29, 2024
@donnchawp donnchawp requested a review from a team October 29, 2024 17:29
@donnchawp donnchawp self-assigned this Oct 29, 2024
Copy link
Contributor

github-actions bot commented Oct 29, 2024

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Choose a review path based on your changes:
    • A. Team Review: add the "[Status] Needs Team Review" label
      • For most changes, including minor cross-team impacts.
      • Example: Updating a team-specific component or a small change to a shared library.
    • B. Crew Review: add the "[Status] Needs Review" label
      • For significant changes to core functionality.
      • Example: Major updates to a shared library or complex features.
    • C. Both: Start with Team, then request Crew
      • For complex changes or when you need extra confidence.
      • Example: Refactor affecting multiple systems.
  3. Get at least one approval before merging.

Still unsure? Reach out in #jetpack-developers for guidance!


Super Cache plugin:

  • Next scheduled release: none scheduled.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions github-actions bot added the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Oct 29, 2024
@donnchawp donnchawp added [Status] Needs Team Review and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Dec 18, 2024
Copy link
Member

@dilirity dilirity left a comment

Choose a reason for hiding this comment

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

Really appreciate the thorough testing instructions!

Testing was successful and code looks good.

:shipit:

@donnchawp donnchawp merged commit 440a234 into trunk Dec 19, 2024
55 checks passed
@donnchawp donnchawp deleted the update/super-cache/get-apache-headers branch December 19, 2024 08:19
@github-actions github-actions bot added this to the super-cache/1.12.5 milestone Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Plugin] Super Cache A fast caching plugin for WordPress. [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants