From 7db5b1eba33bade54860ed71e1a74715dd4fde92 Mon Sep 17 00:00:00 2001 From: Anthony Seure Date: Fri, 9 Feb 2024 12:08:12 +0100 Subject: [PATCH] CUSTESC-36595: Retrieve the Wordpress domain only from the active zone We recently noticed that a user got its zone incorrectly reported as inactive by the Wordpress plugin. After some investigations, it seems that two zones actually existed: an old purged one, and a new active zone. To guarantee that the plugin always retrieve the active one, if any, this commit changes the zone retrieval call to the Cloudflare API by adding a `status=active` query parameter to the request, [as documented here](https://developers.cloudflare.com/api/operations/zones-get). --- src/WordPress/ClientActions.php | 10 +++++++++- src/WordPress/WordPressClientAPI.php | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/WordPress/ClientActions.php b/src/WordPress/ClientActions.php index cb53bc22..a395d265 100644 --- a/src/WordPress/ClientActions.php +++ b/src/WordPress/ClientActions.php @@ -44,7 +44,15 @@ public function returnWordPressDomain() // We tried to fetch a zone but it's possible we're using an API token, // So try again with a zone name filtered API call if (!$this->api->responseOk($response)) { - $zoneRequest = new Request('GET', 'zones/', array('name' => idn_to_ascii($this->wordpressAPI->getOriginalDomain(), IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46), array())); + $zoneRequest = new Request( + 'GET', + 'zones/', + array( + 'name' => idn_to_ascii($this->wordpressAPI->getOriginalDomain(), IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46), + 'status' => 'active', + ), + null + ); $zoneResponse = $this->api->callAPI($zoneRequest); return $zoneResponse; diff --git a/src/WordPress/WordPressClientAPI.php b/src/WordPress/WordPressClientAPI.php index 66ea19b5..a8ddecf5 100644 --- a/src/WordPress/WordPressClientAPI.php +++ b/src/WordPress/WordPressClientAPI.php @@ -22,7 +22,7 @@ public function getZoneTag($zone_name) return $zone_tag; } - $request = new Request('GET', 'zones/', array('name' => $zone_name), array()); + $request = new Request('GET', 'zones/', array('name' => $zone_name, 'status' => 'active'), null); $response = $this->callAPI($request); $zone_tag = null;