Skip to content

Commit

Permalink
CUSTESC-36595: Retrieve the Wordpress domain only from the active zone
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
aseure committed Feb 26, 2024
1 parent 4d53897 commit 7db5b1e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/WordPress/ClientActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/WordPress/WordPressClientAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7db5b1e

Please sign in to comment.