Problem/Motivation

Settings page of the module crashes when there are more than 20 zones available for selection.

Steps to reproduce 1.x

After upgrading to 8.x.-1.0-beta3 or 2.x and trying to go to the settings page/or trying to setup the module first time

    Unable to connect to CloudFlare in order to validate credentials. Please try again later. Error message: Client error: `GET https://api.cloudflare.com/client/v4/zones?page=1&per_page=20&match=all` resulted in a `429 Too Many Requests` response: {"success":false,"errors":[{"code":10100,"message":"More than 1200 requests per 300 seconds reached. Please wait and con (truncated...)
    Unable to connect to CloudFlare in order to validate credentials. Please try again later. Error message: Client error: `GET https://api.cloudflare.com/client/v4/zones?page=0&per_page=20&match=all` resulted in a `429 Too Many Requests` response: {"success":false,"errors":[{"code":10100,"message":"More than 1200 requests per 300 seconds reached. Please wait and con (truncated...)
  • Upgrade module to 8.x.-1.0-beta3
  • Navigate to admin/config/services/cloudflare
  • Page times out
  • Reload page see error at the top.

Steps to reproduce 2.x

On initial setup - try to press Next after providing credentials and see the page crash
On existing setup - visit the module settings page

Proposed resolution

Fix the code

Remaining tasks

Test

Comments

johnpicozzi created an issue. See original summary.

maxmendez’s picture

StatusFileSize
new519 bytes

I faced this issue in my account that have more that one page of zones, reviewing the logic Zone->list Zones seems that creates an infinite loop.

Here my approach to fixed it.

maxmendez’s picture

Version: 8.x-1.0-beta3 » 2.0.x-dev
maxmendez’s picture

StatusFileSize
new825 bytes

Fixed and error in the while condition.

brunapimenta’s picture

Priority: Normal » Major
Status: Active » Reviewed & tested by the community

During the development of #3362051 - Cloudflare PHP SDK is abandoned, affects v1 and v2 I could face the same issue and this solution worked perfectly. :)

rosk0’s picture

Component: User interface » Code
Status: Reviewed & tested by the community » Needs work
Issue tags: -Cloudflare +Needs issue summary update, +Needs tests

I like the patch , but there is more works needs to happen here:

emil stoianov’s picture

Here is the patch from the duplicate issue
It will not make additional request if there is only one page.
The initial request is hardcoded to get the first page and additional requests (to get the next pages) will be made only if current page is less then total pages.

If someone knows how to create a test for this case please do.