Opened 3 months ago
Closed 3 months ago
#63267 closed defect (bug) (fixed)
Coding Standards: Check for an empty $old_email first in wp_site_admin_email_change_notification()
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.9 | Priority: | normal |
Severity: | normal | Version: | |
Component: | General | Keywords: | has-patch |
Focuses: | coding-standards | Cc: |
Description
In the wp_site_admin_email_change_notification()
function, the current logic checks the $old_email
variable for a specific default value before checking if it's empty:
<?php if ( 'you@example.com' === $old_email || empty( $old_email ) ) { $send = false; }
This should be reordered to first check if $old_email
is empty:
<?php if ( empty( $old_email ) || 'you@example.com' === $old_email ) { $send = false; }
This change follows a common best practice: always check for empty or null values first to avoid unnecessary comparisons or potential errors. It also aligns better with readability and expected evaluation flow.
Change History (9)
This ticket was mentioned in PR #8677 on WordPress/wordpress-develop by @dilipbheda.
3 months ago
#1
#3
@
3 months ago
@Presskopp I found it in the GitHub repo here: - https://github.com/WordPress/wordpress-develop/blob/a04a13a1d0039b6054a4276def28eedecc9cb9ad/src/wp-includes/functions.php#L8122
#4
@
3 months ago
I think it changed 7 days ago with this [GitHub issue]https://github.com/dilipbheda/wordpress-develop/issues/62211, but I can't access it to review the changes.
How comes the code is different on https://developer.wordpress.org/reference/functions/wp_site_admin_email_change_notification/ ?