Skip to content
Open
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
32 changes: 31 additions & 1 deletion inc/models/class-domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@
*/
protected $primary_domain = false;

/**
* Original primary_domain value before changes (for tracking edits).
*
* @since 2.0.0
* @var boolean|null
*/
protected $original_primary;

/**
* Should this domain be forced to be used only on HTTPS?
*
Expand Down Expand Up @@ -296,6 +304,10 @@
*/
public function set_primary_domain($primary_domain): void {

if ($this->id > 0 && !isset($this->original_primary)) {

Check failure on line 307 in inc/models/class-domain.php

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Expected 1 space after "!"; 0 found
$this->original_primary = $this->primary_domain;
}
Comment on lines +307 to +309
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix code style: add space after negation operator.

Static analysis flagged a missing space after !.

Apply this diff:

-		if ($this->id > 0 && !isset($this->original_primary)) {
+		if ($this->id > 0 && ! isset($this->original_primary)) {
🧰 Tools
🪛 GitHub Check: Code Quality Checks

[failure] 307-307:
Expected 1 space after "!"; 0 found

🤖 Prompt for AI Agents
In inc/models/class-domain.php around lines 307 to 309, the negation operator is
missing a space; change the conditional to add a space after the '!' so it reads
with '! isset(...)' (i.e. ensure there is a space between the '!' and the
following token) to satisfy the code style/static analysis.


$this->primary_domain = $primary_domain;
}

Expand Down Expand Up @@ -483,6 +495,8 @@

$before_changes = clone $this;

$was_new = ! $this->exists();

$results = parent::save();

if (is_wp_error($results) === false) {
Expand Down Expand Up @@ -517,14 +531,30 @@
*/
do_action_deprecated('mercator.mapping.updated', $deprecated_args, '2.0.0', 'wu_domain_post_save');
}

Check failure on line 534 in inc/models/class-domain.php

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Whitespace found at end of line
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove trailing whitespace.

Static analysis flagged trailing whitespace at this line.

🧰 Tools
🪛 GitHub Check: Code Quality Checks

[failure] 534-534:
Whitespace found at end of line

🤖 Prompt for AI Agents
In inc/models/class-domain.php at line 534, there is trailing whitespace at the
end of the line; remove any extra spaces or tabs after the code on that line so
the line ends immediately after the last visible character, then save the file
to eliminate the static-analysis warning.

/*
* Resets cache.
*
* This will make sure the list of domains gets rebuild
* after a change is made.
*/
wp_cache_flush();

/*
* If this domain was just set as primary, unset other primaries for this site.
*/
if ($this->primary_domain && ($was_new || (isset($this->original_primary) && ! $this->original_primary))) {
$old_primary_domains = wu_get_domains(
[
'primary_domain' => true,
'blog_id' => $this->blog_id,
'id__not_in' => [$this->id],
'fields' => 'ids',
]
);

do_action('wu_async_remove_old_primary_domains', $old_primary_domains);
}
}

return $results;
Expand Down
Loading