-
Notifications
You must be signed in to change notification settings - Fork 821
Status: add new class used to classify requests on a site. #43843
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
base: trunk
Are you sure you want to change the base?
Conversation
This function currently lives in the Jetpack plugin only, but would be needed outside of the Jetpack plugin (for example for #43413).
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Code Coverage Summary1 file is newly checked for coverage.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new Request class to classify site requests outside the Jetpack plugin, and updates the corresponding tests and changelog.
- Adds Request class with methods to determine if a request is for the frontend and to manage Vary headers.
- Updates the patchwork.json test configuration to include additional redeclarable header functions.
- Updates the changelog to reflect the addition.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
File | Description |
---|---|
projects/packages/status/tests/php/patchwork.json | Added new redeclarable header functions to the array. |
projects/packages/status/src/class-request.php | Introduced a new Request class with methods for frontend detection and Vary header handling. |
projects/packages/status/changelog/add-is-frontend-status | Changelog entry describing the minor addition of the Request class. |
Comments suppressed due to low confidence (1)
projects/packages/status/tests/php/patchwork.json:6
- Consider adding tests to verify that the additional redeclarable header functions ('headers_sent', 'headers_list', and 'header') behave as expected in various request scenarios.
"headers_sent",
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable, and has coverage. The only comment I really care about is line 69, the rest are ok with me to ignore if you disagree.
projects/packages/status/src/class-request.php 31/31 (100.00%) 💚
💚
* Go through headers and get a list of Vary headers to add, | ||
* including a Vary Accept header if necessary. | ||
* | ||
* @since 12.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@since 12.2
doesn't make sense in the context of the Status package.
|
||
/** | ||
* Go through headers and get a list of Vary headers to add, | ||
* including a Vary Accept header if necessary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we update this while we're here?
* including a Vary Accept header if necessary. | |
* including Vary on Accept and Content-Type if necessary. |
|
||
return array( | ||
'frontend request' => array( | ||
'scenario_name' => 'frontend request', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The scenario_name parameter seems kind of redundant, since it's already the key for the test and will be included in the output
For example,
1) Automattic\Jetpack\Status\Request_Test::test_is_frontend_scenarios with data set "frontend request" ('frontend request', [false, false, false, false, false, false, false], [], false, true)
Failed scenario: frontend request
Failed asserting that true matches expected false.
already says with data set "frontend request"
.
Proposed changes:
jetpack_is_frontend
currently lives in the Jetpack plugin only, but would be needed outside of the Jetpack plugin (for example for #43413).In phase 2, we'll replace usage of the function everywhere where it is used, and deprecate the function.
Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions: