[wp-trac] [WordPress Trac] #63267: Coding Standards: Check for an empty $old_email first in wp_site_admin_email_change_notification()

WordPress Trac noreply at wordpress.org
Fri Apr 11 13:02:07 UTC 2025


#63267: Coding Standards: Check for an empty $old_email first in
wp_site_admin_email_change_notification()
------------------------------+-----------------------------
 Reporter:  dilipbheda        |      Owner:  (none)
     Type:  defect (bug)      |     Status:  new
 Priority:  normal            |  Milestone:  Awaiting Review
Component:  General           |    Version:
 Severity:  normal            |   Keywords:  has-patch
  Focuses:  coding-standards  |
------------------------------+-----------------------------
 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
 <?php
 if ( 'you at example.com' === $old_email || empty( $old_email ) ) {
         $send = false;
 }
 }}}



 This should be reordered to first check if `$old_email` is empty:


 {{{#!php
 <?php
 if ( empty( $old_email ) || 'you at 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.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/63267>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list