Skip to content

quality-debt: inc/models/class-site.php — PR #755 review feedback (high) #758

@superdav42

Description

@superdav42

Unactioned Review Feedback

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


HIGH: coderabbit (coderabbitai[bot])

File: inc/models/class-site.php:336
⚠️ Potential issue | 🟠 Major

Defaulting site_id to 1 can create sites in the wrong network.

Line 336 hard-defaults to 1, and save() later uses $this->get_site_id() ?: get_current_network_id(), so omitted site_id never falls back to the current network. On multi-network installs, this can route creations to network 1 unintentionally.

Suggested fix
-			'site_id'           => 'integer|default:1',
+			'site_id'           => 'integer|default:',
-	protected $site_id = 1;
+	protected $site_id = 0;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

			// site_id is the network id; defaults to 1 (the main network) in
			// the model, so it's optional for a regular WordPress subsite.
			'site_id'           => 'integer|default:',
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@inc/models/class-site.php` around lines 334 - 336, The schema entry for
'site_id' currently hard-defaults to 1 causing creations to always use network
1; remove that hard-default (or change it to allow null) so the validator rule
is just 'integer' (or 'integer|nullable') and let the existing save() logic
(which calls $this->get_site_id() ?: get_current_network_id()) determine the
correct network; update the 'site_id' rule in the class-site.php model instead
of defaulting to 1 to avoid forcing network 1 on multi-network installs.

View comment


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


To approve or decline, use one of:

  • sudo aidevops approve issue <number> -- cryptographically signs approval for automated dispatch
  • Comment declined: <reason> -- closes this issue (include your reason after the colon)

aidevops.sh v3.6.166 automated scan.

Metadata

Metadata

Assignees

No one assigned

    Labels

    origin:workerpriority:highHigh severity — significant quality issuequality-debtUnactioned review feedback from merged PRssource:review-feedbackAuto-created by quality-feedback-helper.shstatus:availableTask is available for claimingtier:reasoningRoute 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