Skip to content

autoPagingInterator() fails if the last collection item is deleted #1264

@snez

Description

@snez

When the autoPagingInterator() is used with deletes, only 1 page can be processed, because the last item of the current collection has been deleted, therefore the pager cannot find it to build the 2nd page.

For example (PHP)

        $products = $stripe->products->all(['limit' => 100]);
        foreach ($products->autoPagingIterator() as $product)
        {
            $product->delete();
        }

The above will crash with No such product: 'prod_LIvx6FPSkqMLyL' because the last item in the collection no longer exists.

This can be a problem in a number of cases, i.e.

  • Looping through and deleting duplicated saved payment methods based on fingerprint data.
  • Test suites where Stripe test data must be cleared before the test suite starts.
  • Synchronizing local products with Stripe products in cron jobs.
  • etc

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions