Skip to content

Conversation

@emdashcodes
Copy link
Contributor

@emdashcodes emdashcodes commented Sep 18, 2025

This PR uses link_header instead of add_link to add next/prev pagination links to keep the response as a pure array.

When using add_link, _links is added to the response body, converting it from an array to a JSON object like {"0": {...}, "_links": {...}}.

Note that this is a breaking fix from 0.1, though you would have only noticed if you set per_page to something low or had 50+ abilities.

See also #60 (comment).

Testing Instructions

  • Make sure that all unit tests pass
  • Make a test GET request to /wp/v2/abilities?per_page=1 and see that both X-WP-Total and X-WP-TotalPages are set
  • Make a test GET request to /wp/v2/abilities?per_page=1&page=2 and see that the response is an array of items

@emdashcodes emdashcodes requested a review from gziolo September 18, 2025 13:46
@emdashcodes emdashcodes self-assigned this Sep 18, 2025
@github-actions
Copy link

github-actions bot commented Sep 18, 2025

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: emdashcodes <[email protected]>
Co-authored-by: gziolo <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@codecov
Copy link

codecov bot commented Sep 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.33%. Comparing base (59d8ec6) to head (1d4d183).
⚠️ Report is 1 commits behind head on trunk.

Additional details and impacted files
@@            Coverage Diff            @@
##              trunk      #81   +/-   ##
=========================================
  Coverage     83.33%   83.33%           
  Complexity       96       96           
=========================================
  Files             8        8           
  Lines           516      516           
=========================================
  Hits            430      430           
  Misses           86       86           
Flag Coverage Δ
unit 83.33% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gziolo gziolo added the [Type] Bug Something isn't working label Sep 18, 2025
Copy link
Member

@gziolo gziolo 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 very much for cherry-picking changes from #60 👍🏻

@gziolo gziolo merged commit 6143ba3 into trunk Sep 18, 2025
20 checks passed
@gziolo gziolo deleted the fix/rest-api-pagination-headers branch September 18, 2025 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants