[wp-trac] [WordPress Trac] #58152: Possible variable re-use

WordPress Trac noreply at wordpress.org
Wed Apr 19 23:31:35 UTC 2023


#58152: Possible variable re-use
-----------------------------------+------------------------------
 Reporter:  mujuonly               |       Owner:  mujuonly
     Type:  enhancement            |      Status:  assigned
 Priority:  normal                 |   Milestone:  Awaiting Review
Component:  Users                  |     Version:  trunk
 Severity:  normal                 |  Resolution:
 Keywords:  has-patch 2nd-opinion  |     Focuses:
-----------------------------------+------------------------------
Changes (by SergeyBiryukov):

 * keywords:  has-patch => has-patch 2nd-opinion


Comment:

 Thanks for the PR!

 It looks like the purpose of the `$spam` variable here is to be included
 in the `compact()` call in [source:tags/6.2/src/wp-
 includes/user.php?marks=2330#L2321 line 2330].

 Reading the [source:tags/6.2/src/wp-includes/user.php?marks=2330#L2450
 DocBlock above the suggested change], it makes it immediately clear what
 `$userdata` is: the raw array of data passed to `wp_insert_user()`, and
 `$userdata['spam']` is a part of that array. This naming also seems more
 consistent when being compared with `$old_user_data->spam`.

 If we replace it with `$spam`, anyone reviewing the code would then have
 to spend some more time to find where that variable is defined.

 So I don't see any benefits in changing this code, it seems fine as is to
 me.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58152#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list