Conversation
WalkthroughAdds a new Hestia Control Panel host provider integration with domain alias add/remove and connection test via Hestia API. Updates Domain Manager to load the Hestia provider and fixes a hook to pass two arguments to the deletion handler. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant DM as Domain Manager
participant HP as Hestia_Host_Provider
participant HA as Hestia API
rect rgb(235, 245, 255)
note over DM,HP: Add domain flow
DM->>HP: on_add_domain(domain, site_id)
HP->>HP: Validate constants and inputs
HP->>HA: v-add-web-domain-alias (account, web_domain, domain)
HA-->>HP: Result / Error
alt www alias required
HP->>HA: v-add-web-domain-alias (..., "www." + domain)
HA-->>HP: Result / Error
end
HP-->>DM: Return (log outcome)
end
sequenceDiagram
autonumber
participant DM as Domain Manager
participant HP as Hestia_Host_Provider
participant HA as Hestia API
rect rgb(245, 235, 255)
note over DM,HP: Remove domain flow
DM->>HP: on_remove_domain(domain, site_id)
HP->>HP: Validate constants and inputs
HP->>HA: v-delete-web-domain-alias (account, web_domain, domain)
HA-->>HP: Result / Error
opt if www alias exists
HP->>HA: v-delete-web-domain-alias (..., "www." + domain)
HA-->>HP: Result / Error
end
HP-->>DM: Return (log outcome)
end
sequenceDiagram
autonumber
participant Admin as Admin UI
participant HP as Hestia_Host_Provider
participant HA as Hestia API
rect rgb(235, 255, 235)
note over Admin,HP: Connection test
Admin->>HP: test_connection()
HP->>HA: v-list-web-domains (account)
HA-->>HP: Domains / Error
HP-->>Admin: Result (log outcome)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
inc/integrations/host-providers/class-hestia-host-provider.php (3)
158-161: Avoid PHP 8‑only str_starts_with for wider compatibility.Replace with strpos to support PHP < 8 (and for consistency with Domain_Manager).
Confirm the project’s minimum PHP version. If it’s < 8.0, apply:
- if (! str_starts_with($domain, 'www.') && \WP_Ultimo\Managers\Domain_Manager::get_instance()->should_create_www_subdomain($domain)) { + if (0 !== strpos($domain, 'www.') && \WP_Ultimo\Managers\Domain_Manager::get_instance()->should_create_www_subdomain($domain)) { ... - if (! str_starts_with($domain, 'www.')) { + if (0 !== strpos($domain, 'www.')) {Also applies to: 186-188
128-134: Use ‘default’ instead of ‘value’ for field default.Provider fields elsewhere use ‘default’. Using ‘value’ may not prefill the UI.
- 'value' => 'yes', + 'default' => 'yes',
143-143: Silence unused parameter warnings (PHPMD).Parameters are required by the interface but unused here.
public function on_add_domain($domain, $site_id): void { - + // Unused in this provider. + unset($site_id);public function on_remove_domain($domain, $site_id): void { - + // Unused in this provider. + unset($site_id);-public function on_add_subdomain($subdomain, $site_id) {} +public function on_add_subdomain($subdomain, $site_id) { + // Unused in this provider. + unset($subdomain, $site_id); +}-public function on_remove_subdomain($subdomain, $site_id) {} +public function on_remove_subdomain($subdomain, $site_id) { + // Unused in this provider. + unset($subdomain, $site_id); +}Also applies to: 170-170, 197-197, 205-205
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
assets/img/hosts/hestia.svgis excluded by!**/*.svg
📒 Files selected for processing (2)
inc/integrations/host-providers/class-hestia-host-provider.php(1 hunks)inc/managers/class-domain-manager.php(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
inc/integrations/host-providers/class-hestia-host-provider.php (3)
inc/integrations/host-providers/class-base-host-provider.php (2)
Base_Host_Provider(20-651)supports(332-335)inc/functions/helper.php (1)
wu_log_add(208-211)inc/managers/class-domain-manager.php (2)
Domain_Manager(27-1139)should_create_www_subdomain(459-482)
inc/managers/class-domain-manager.php (1)
inc/integrations/host-providers/class-hestia-host-provider.php (1)
Hestia_Host_Provider(24-337)
🪛 PHPMD (2.15.0)
inc/integrations/host-providers/class-hestia-host-provider.php
143-143: Avoid unused parameters such as '$site_id'. (undefined)
(UnusedFormalParameter)
170-170: Avoid unused parameters such as '$site_id'. (undefined)
(UnusedFormalParameter)
197-197: Avoid unused parameters such as '$subdomain'. (undefined)
(UnusedFormalParameter)
197-197: Avoid unused parameters such as '$site_id'. (undefined)
(UnusedFormalParameter)
205-205: Avoid unused parameters such as '$subdomain'. (undefined)
(UnusedFormalParameter)
205-205: Avoid unused parameters such as '$site_id'. (undefined)
(UnusedFormalParameter)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: cypress (8.2, chrome)
- GitHub Check: cypress (8.1, chrome)
🔇 Additional comments (2)
inc/managers/class-domain-manager.php (2)
159-159: Hook args count matches handler signature; good change.Switching to 2 accepted args aligns with handle_domain_deleted($result, $domain).
985-989: Hestia provider is now loaded; looks good.Ensure autoloading picks up WP_Ultimo\Integrations\Host_Providers\Hestia_Host_Provider and that hestia.svg exists at img/hosts.
| // With returncode=yes Hestia typically returns numeric code (0 success). Keep raw for logs. | ||
| $trim = trim((string) $raw); | ||
|
|
||
| if ('0' === $trim) { | ||
| return '0'; | ||
| } | ||
|
|
||
| // Try to decode JSON if present, otherwise return raw string | ||
| $json = json_decode($raw); | ||
| return null !== $json ? $json : $raw; |
There was a problem hiding this comment.
Non‑zero Hestia return codes are treated as success (critical).
With returncode=yes, Hestia returns numeric codes; only 0 is success. Non‑zero should be WP_Error, not logged as success.
Apply this fix:
- // With returncode=yes Hestia typically returns numeric code (0 success). Keep raw for logs.
- $trim = trim((string) $raw);
-
- if ('0' === $trim) {
- return '0';
- }
-
- // Try to decode JSON if present, otherwise return raw string
- $json = json_decode($raw);
- return null !== $json ? $json : $raw;
+ // With returncode=yes Hestia typically returns numeric code (0 success).
+ $trim = trim((string) $raw);
+ if (ctype_digit($trim)) {
+ if ($trim === '0') {
+ return '0';
+ }
+ /* translators: %s: Hestia error code */
+ return new \WP_Error('wu_hestia_returncode', sprintf(__('Hestia API returned error code %s', 'ultimate-multisite'), $trim));
+ }
+
+ // Try to decode JSON if present, otherwise return raw string.
+ $json = json_decode($raw);
+ return null !== $json ? $json : $raw;🤖 Prompt for AI Agents
In inc/integrations/host-providers/class-hestia-host-provider.php around lines
326 to 335, non‑zero Hestia return codes are currently treated as success;
change the logic so that after trimming the raw output you detect numeric
non‑zero return codes and return a WP_Error instead of success. Specifically:
trim the output, if it equals '0' return '0' as before; if it is a numeric
string and not '0' construct and return a new WP_Error containing a clear error
code and message (include the numeric code and the raw/decoded response for
context); otherwise keep the existing JSON decode fallback and return the
decoded value or raw string.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation