Repository navigation
Conversation
The 7 *Page/Data/Pagination.php classes (Contacts, Templates, Webhooks, WebhookEvents, Conversations, Calls, VoiceAgents) only declared hasMore, so reading ->page, ->pageSize, ->totalCount, or ->totalPages threw, even though the API has always returned all of them (issue sentdm#47). Fixing that surfaced two deeper bugs in the same auto-pagination path. hasMore itself never hydrated either, because *Page::__construct() calls __unserialize() directly on raw wire JSON, bypassing the normal name translation every other model goes through. nextRequest() also never advanced the page number: array_merge_recursive() on a scalar against an array appends rather than overwrites, and once that's fixed, the stale query string baked into the reused request path collides with the new one unless stripped first. Repoints each *Page/Data.php at the existing SentDm\Webhooks\PaginationMeta type (already used correctly by CallsList and five other sibling response types), extends the second-pass re-coercion workaround list items already get to cover pagination too, and fixes nextRequest()'s page increment and stale query string.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Thanks, this is a thorough one, and all three findings check out. Here's how we're taking them, because the fixes belong upstream of this repository:
I'll leave this PR open as the reference until those land, then close it in favour of the generated fix. Your two-page test is exactly the regression test the template needs, and the generator issue points at it. |
|
Follow-up: the two page bugs are going in now as #83, a narrower version of your change that touches only the seven page classes (the constructor's second pass for |
|
Closing now that both halves have shipped from the right places: 0.44.1 fixed hasNextPage() and the next-page request (#83, co-authored with you), and 0.45.0 adds page, pageSize, totalCount and totalPages on every Pagination model, generated from the API's shared pagination schema. Python, TypeScript, Go and Ruby got the same fields in their releases today. Thank you for the diagnosis and the two-page test, which is now the regression test in this repository. |
What's wrong
Three bugs in the same ten lines of code, found while fixing the first one.
1. Pagination fields missing (issue #47). All 7
*Page/Data/Pagination.phpclasses(Contacts, Templates, Webhooks, WebhookEvents, Conversations, Calls, VoiceAgents) declare
only
has_more. Reading->page,->pageSize,->totalCount,->totalPagesthrows, eventhough the API has always returned all of them. Confirmed against a fresh pull of
api.sent.dm/swagger/v3/swagger.json: all 7 resolve to the sameSharedPaginationMetaschema that
CallsListand 5 other sibling response types already use correctly.2.
has_moreitself never hydrates, sohasNextPage()always returns false.*Page::__construct()calls__unserialize()directly on raw wire JSON, skipping thenormal name-translation path every other model goes through. List items (
contacts,calls, etc.) escape this because they're typedmixedand get manually re-coerced rightafter, a workaround already in every one of these files. Nobody added that same fix for
pagination, sohas_moresilently fails to translate, andnextRequest()'s??swallows the resulting error:
3. The next request never advances the page.
merges a scalar against an array under the same key.
array_merge_recursiveappendsinstead of overwriting, so
pagestays1forever:Fixing that directly surfaces a fourth detail:
requestInfo['path']is the fully resolvedURI, query string included.
Util::joinUri()re-parses that embedded query and merges itwith the new one, so the stale
page=1survives next to the newpage=2unless the querystring is stripped off
pathfirst.Checked the other SDKs
has_more-only shape.PaginationMeta.Checked the commit history too: PHP, Java, and C# each got a commit with the identical
message,
feat(api): configure page_number pagination for the v3 list endpoints, from thesame generator pipeline, same day. Java and C# generated the full
PaginationMetafromthat commit. PHP generated the
has_more-only stub. Same spec, same rollout, differentoutput per language. This PR is PHP catching up to where its siblings already landed.
Bugs 2 and 3 are PHP-specific plumbing, not checked against the other SDKs.
What changed
For each of the 7 resources:
*Page/Data.phpnow typespaginationasSentDm\Webhooks\PaginationMeta. The 7 stalePagination.phpfiles are deleted.*Page.php's constructor gets the same second-pass re-coercion forpaginationthatlist items already get.
nextRequest()sets$nextRequest['query']['page']directly instead of the brokenmerge, and strips the stale query string off
pathfirst.Before:
After:
Compatibility
Removes the 7 public
Paginationclasses outright rather than keeping deprecated aliases.Each one exposed exactly one field that never hydrated anyway, so there was nothing working
to depend on. Matches the Java fix for the same bug: that SDK's old class was renamed and
replaced outright in the same commit, no alias kept.
How I verified it
Added
tests/PaginationFieldsTest.php: one hydration test per resource, plus a realtwo-page test for contacts that mocks page 1 and page 2, calls
getNextPage(), and assertsthe second HTTP request actually carries
page=2../scripts/lintand./scripts/testboth pass locally, full existing suite included.