Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CUSTESC-36595: Retrieve the Wordpress domain only from the active zone #532

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'll also want to update the call above on L42 in case the user is using API keys. iirc, you'll need to modify $this->request to include the params (or find the caller and update it there which is probably the more sustainable way forward).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following your suggestion, I've only changed the WordPressClientAPI.php file, which is the only other place I found performing a GET zones/ which may benefit from this.

There is a last GET zones/ call in https://github.com/aseure/Cloudflare-WordPress/blob/5c147468490835c94b5c8dd69952f80d23f30672/src/API/AbstractPluginActions.php#L99 but since it is only a call to check API key and email validity, I did not bother changing it to limit any unknown negative impact.

$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
Loading