-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
62292 warning in wp rest posts controllerget items #8021
base: trunk
Are you sure you want to change the base?
62292 warning in wp rest posts controllerget items #8021
Conversation
…`WP-REST-Global-Styles-Revisions-Controller-Test.php` file (previously named `rest-global-styles-revisions-controller.php`). This test verifies the pagination functionality of the REST API endpoint for global styles revisions. Here's a breakdown: 1. **Revision Creation:** The test begins by creating 15 revisions for a global style (using `self::$global_styles_id`). This sets up the scenario for testing pagination. 2. **Offset Test:** It then makes a request to the `/wp/v2/global-styles/{global_style_id}/revisions` endpoint with `offset=5` and `per_page=5`. This should return revisions 6-10. The test asserts: - A 200 OK status code. - 5 items in the response data. - `X-WP-Total` header equals 15 (total revisions). - `X-WP-TotalPages` header equals 3 (given 5 per page). 3. **Paged Test:** Next, it tests "paged" requests, setting `page=2` and `per_page=6`. This should return revisions 7-12. The assertions are similar to the offset test, checking for 6 items and the same total/total pages headers. 4. **Out of Bounds Test:** Finally, the test attempts to fetch an out-of-bounds page (`page=4`, `per_page=6`). It expects a `rest_revision_invalid_page_number` error with a 400 Bad Request status code, confirming proper handling of invalid pagination parameters. In summary, this new test ensures that the global styles revisions endpoint correctly handles `offset`, `page`, and `per_page` parameters, returns the expected number of results, and provides accurate pagination headers (`X-WP-Total` and `X-WP-TotalPages`). It also tests error handling for invalid page numbers.
…ntrollerget_items
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @[email protected]. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. Core Committers: Use this line as a base for the props when committing in SVN:
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Unified and improved pagination handling in REST API controllers by ensuring 'paged' parameter is checked for existence before casting. Updated tests for global styles, posts, and templates to validate pagination behavior, including edge cases like offsets and out-of-bounds pages. Renamed and reorganized test files for clarity.
…ontrollerget_items' into 62292-Warning-in-WP_REST_Posts_Controllerget_items
Trac ticket: https://core.trac.wordpress.org/ticket/62292