Problem/Motivation

The Cloudflare PHP SDK seems to no longer be maintained. What is the future for this module

Steps to reproduce

Visit this page:

Comment on Github

Proposed resolution

I have none, that's why I'm asking.

Remaining tasks

Move away from the Cloudflare PHP SDK I guess.

User interface changes

None.

API changes

Exactly.

Data model changes

Not sure.

Issue fork cloudflare-3362051

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

hdotnet created an issue. See original summary.

brunapimenta’s picture

Assigned: Unassigned » brunapimenta

I'll start taking a look on suggestion of the Comment on Github, wherein Cloudflare indicates the usage of API directly.

brunapimenta’s picture

Version: 8.x-1.x-dev » 2.0.x-dev

brunapimenta’s picture

Status: Active » Needs review
Related issues: +#3346396: admin/config/services/cloudflare Slow to Load

I've provided a fork removing Cloudflare SDK dependency, for that I've chosen to bring to Cloudflare Drupal module the SDK needed code - in which is the one related to Zone (listing and caching purge).

It was validated using a Drupal vanilla installation, everything worked smoothly after applying #3346396 - admin/config/services/cloudflare Slow to Load solution.

Note
Since SDK code followed an Object-Oriented Programming, I've kept as is. Even though at the end it looked a complex solution to a simple need, it can provide flexibility porting more code from that library on the future.

neclimdul’s picture

oof. I'm going to end up being "that guy that just maintains automated builds of OpenAPI libraries because companies can't be bothered to build a CI."

I'll get something built that can be used as a replacement.

rosk0’s picture

I don't think that copying code from the SDK is a good idea - SDK is old, covers a lot of API endpoints and have a lot of complexity for various use case this module should not need to care about.

Before diving into the solution we need to map out what API endpoints we are actually need to interact with and possibly create child issue to split the work where possible.

I'm not sure, but it feels like this type of change should warrant major version number increase.

And in any case, we need to get #3423376: Add Drupal Gitlab templates merged first.

alexpott’s picture

@RoSk0++ to only bringing in what you need from the SDK. And yes new major sounds like a good idea.

it-cru’s picture

Is maybe Cloudflare SDK not death?

During last composer update I saw a new release 1.4.0 of cloudflare/sdk and also its repo on Github has some activity again. Maybe we should double check this with CF or maintainers of this SDK.

https://github.com/cloudflare/cloudflare-php

gstivanin made their first commit to this issue’s fork.

rosk0’s picture

Assigned: brunapimenta » Unassigned
Status: Needs review » Needs work

Maintainers of the SDK are silent, so I believe we should still keep working in a direction of removing that dependency.

Next steps should be listing out all the API endpoints (together with links to the docs and use cases) that are actually required by this module. From there we can asses what to do next.

We also need to keep in mind that moving forward we only need to support token authentication, as global API key (email + key) is deprecated and could be dropped any minute.

intrafusion’s picture

Title: Cloudflare PHP SDK is abandoned, affects v1 and v2 » Remove Cloudflare SDK dependency due to lack of maintenance

I’ve taken a cursorily glance through the code base and it appears the SDK is only called in 2 files:

  • modules/cloudflarepurger/src/Plugin/Purge/Purger/CloudFlarePurger.php
  • src/Zone.php

So I don’t imagine it’s going to be too much work, I’ll investigate the actual calls and their replacements.

intrafusion’s picture

Zone.php

  1. Adapter\Guzzle wrapper around Guzzle calls
  2. Auth\APIKey wrapper around API key
  3. Auth\APIToken wrapper around API token
  4. Endpoints\Zones calls to https://developers.cloudflare.com/api/resources/zones/methods/list/

CloudFlarePurger.php

  1. Adapter\Guzzle wrapper around Guzzle calls
  2. Auth\APIKey wrapper around API key
  3. Auth\APIToken wrapper around API token
  4. Endpoints\Zones calls to https://developers.cloudflare.com/api/resources/zones/methods/list/ & https://developers.cloudflare.com/api/resources/cache/methods/purge/

intrafusion changed the visibility of the branch 3362051-cloudflare-php-sdk to hidden.

bkosborne made their first commit to this issue’s fork.

bkosborne’s picture

Yes please. We don't use much from the SDK, should be straight forward to decouple from it. I'll get started on this now. I also agree that just copying code from the SDK isn't wise. We can get even simpler.

rosk0 changed the visibility of the branch 8.x-1.x to hidden.

timwood’s picture

charginghawk’s picture

Priority: Normal » Major

Bumping priority to major since the Cloudflare SDK has a dependency conflict with the simple_oauth module (installed on ~16,000 sites). Basically the Cloudflare SDK requires psr/http-message ^1.0 and simple_oauth releases for Drupal 11 require oauth2-server ^9.0 which requires psr/http-message ^2.0. So you can't update to D11 if you have both the Cloudflare module and the simple_oauth module.

bernardopaulino’s picture

This is really unfortunate, I cannot install this module due to a dependency on psr/http-message ^2.0 since I am using simple_oauth module.

intrafusion’s picture

It's possible to run this on Drupal 11 with the forked repo from https://github.com/davidbarratt/cloudflare-php/tree/psr-http-upgrade

I don't know the composer commands, but I manually added this to the repositories section:

{
  "type": "github",
  "url": "https://github.com/davidbarratt/cloudflare-php"
}

And added to the require section:

...
"cloudflare/sdk": "dev-psr-http-upgrade as 1.4.0",
...
"drupal/cloudflare": "^2.0@beta",
...

And finally composer update to install everything

philltran made their first commit to this issue’s fork.

philltran’s picture

Status: Needs work » Needs review

Please test this version of the module with Cloudflare SDK dependency removed. So far it is working in my testing.

Some of the edits to README and docs can be split off to a different issue if desired by the maintainer. Since, this is a fairly large re-write I included the extra changes into this branch.

rosk0’s picture

Assigned: Unassigned » rosk0
Status: Needs review » Active

Thanks @philltran!

I've done bunch of changes on the MR, need to go through it again, but believe we are really close.

I will release a new beta when we merge this.