Skip to content
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

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

Open
ruslanlazin opened this issue Nov 18, 2024 · 0 comments
Open

Comments

@ruslanlazin
Copy link

ruslanlazin commented Nov 18, 2024

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant