Skip to content

Pageable sdk methods for none pageable Twilio endpoints. Possible loop #833

@ruslanlazin

Description

@ruslanlazin

Issue Summary

Twilio php sdk functions:

  • content->v2->contentAndApprovals->stream()
  • content->v2->contentAndApprovals->read()
  • content->v2->contents->stream()
  • content->v2->contents->read()

provides pageable interface to non pageable Twilio endpoints. Moreover doc above each function says pagination is supported and incorrectly explains how to use it.
In the same time Twilio doc says nothing about pagination support for these endpoints.
Attempt to use the functions with pagination (according to doc above them) leads to infinitive template downloading loop.

Steps to Reproduce. Scenario 1

  1. Create 51+ templates in your Twilio account
  2. Call $twilioClient->content->v2->contentAndApprovals->read(); (no params, all default values)
  3. See function in infinitive loop.

Steps to Reproduce. Scenario 2

  1. Create 11+ templates in your Twilio account
  2. Try to load them (max 100, page size 10).
    $templates = $twilioClient->content->v2->contentAndApprovals->stream([], 100, 10);
  3. Iterate $templates.
  4. See client ten times returns you first ten templates (it loads first 10, then asks 10 more, receives same 10 templates, ... )

Steps to Reproduce. Scenario 3

  1. Create 11+ templates in your Twilio account
  2. Try to load them (no limit, page size 10).
    $twilioClient->content->v2->contentAndApprovals->stream([], null, 10);
  3. See client returns you first ten templates in a loop that never ends.

Code Snippet

  $twilioClient = new Client($sid, $token);
  $templates = $twilioClient->content->v2->contentAndApprovals->stream([], null, 10);
  foreach ($templates as $template) {
      echo $template->sid;
   }
 // you need to have more than 10 templates to see infinitive loop with infinitive requests to Twilio API

Technical details:

  • twilio-php version: 8.3.7
  • php version: 8.2

Possible solution:

  • Remove non supported arguments (pageSize) from method signature.
  • Update invalid php doc

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: mediumImportant but not urgent; Workaround availabletype: bugbug in the library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions