Skip to content

quality-debt: inc/models/class-site.php β€” PR #1125 review feedback (medium)Β #1138

@superdav42

Description

@superdav42

Unactioned Review Feedback

Source PR: #1125
File: inc/models/class-site.php
Reviewers: coderabbit
Findings: 1
Max severity: medium


MEDIUM: coderabbit (coderabbitai[bot])

File: inc/models/class-site.php:1783
πŸ› οΈ Refactor suggestion | 🟠 Major | ⚑ Quick win

Return a WP_Error from the exception path too.

This branch reintroduces a generic false failure mode, so callers still cannot handle all delete failures uniformly. Wrapping the caught throwable in a translated WP_Error keeps delete() consistent with the new wp_delete_site() error propagation.

πŸ’‘ Proposed change
 		try {
 			$wp_result = wp_delete_site($this->get_id());
 		} catch (\Throwable $e) {
 			wu_log_add('fatal-error', $e->getMessage(), LogLevel::ERROR);

-			return false;
+			return new \WP_Error(
+				'wu_' . $this->model . '_delete_failed',
+				__('Failed to delete the site.', 'ultimate-multisite')
+			);
 		}

As per coding guidelines: 'Use WP_Error for validation and operation failures, not exceptions. Check is_wp_error() on return values.'

πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@inc/models/class-site.php` around lines 1777 - 1783, The catch block in the
delete() method currently logs the throwable and returns false, reintroducing a
non-WP_Error failure mode; change it to return a WP_Error instead by creating a
new WP_Error (with a machine-readable code like 'site_delete_failed'), a
translated message including $e->getMessage(), and any useful data (e.g.,
'site_id' => $this->get_id()), after calling wu_log_add; update the catch block
around wp_delete_site($this->get_id()) so callers can use is_wp_error()
uniformly.

View comment



Auto-generated by quality-feedback-helper.sh scan-merged. Review each finding and either fix the code or dismiss with a reason.


aidevops.sh v3.14.75 automated scan.

Metadata

Metadata

Assignees

No one assigned

    Labels

    model:opus-4-7Override: route dispatch to claude-opus-4-7 (wins over tier:*)origin:workerAuto-created by pulse labelless backfill (t2112)priority:mediumMedium severity β€” moderate quality issuequality-debtUnactioned review feedback from merged PRssource:review-feedbackAuto-created by quality-feedback-helper.shstatus:availableTask is available for claimingtier:thinkingRoute to opus-tier model for dispatch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions