Repository navigation
Conversation
…ail. On multisite, `user-edit.php` updated `wp_signups` using `$user_login`, which is not set in that scope. In wp-admin it holds the current user's login (set by `setup_userdata()`), so editing another user's email wrote the new address into the editor's signups row instead of the edited user's. Use `$user->user_login`, and unslash the posted email before validating it so addresses with an apostrophe are accepted. See #26805.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
This comment has been minimized.
This comment has been minimized.
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
…an baseline. See #26805.
…into fix/26805-signups-email-update
huzaifaalmesbah
left a comment
There was a problem hiding this comment.
Thanks for picking this up, @erycson! I left a small note inline.
AI Review: Opus 5.5
| $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $_POST['email'], $user_login ) ); | ||
| $email = isset( $_POST['email'] ) ? wp_unslash( $_POST['email'] ) : ''; | ||
|
|
||
| if ( $user->user_login && $email && is_email( $email ) && $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $user->user_login ) ) ) { |
There was a problem hiding this comment.
This one looks like a small gap: the update still runs before edit_user() validates the request. If I enter an email that another account already uses, the edit is rejected with email_exists, but it looks like that email would still be written to this user's signups row.
What do you think about moving it into the ! is_wp_error( $errors ) branch further down and using the saved values?
if ( ! is_wp_error( $errors ) ) {
// Update the email address in signups, if present.
if ( is_multisite() ) {
$user = get_userdata( $user_id );
$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, $user->user_login ) );
}This also covers the apostrophe case without reading $_POST, and the SELECT can go, since an UPDATE with no matching row does nothing. I tried this placement on multisite with accepted, rejected and apostrophe edits, and the rows stayed consistent: commit.
There was a problem hiding this comment.
Good catch, thanks! You're right, the update ran before edit_user() validated the request, so a rejected email could still end up in the signups row. I've moved it into the ! is_wp_error( $errors ) branch and switched to the saved values as you suggested, which also lets the SELECT and the $_POST read go away.
…email-update # Conflicts: # tests/phpstan/baselines/variable.undefined.neon
On multisite,
user-edit.phpupdateswp_signupswith$user_login, which isnot set in that scope. In wp-admin it holds the current user's login (set by
setup_userdata()viawp_set_current_user()), so when an admin who has asignups row edits another user's email, the new address is written into the
admin's row and the edited user's row is left unchanged. If the admin has no
signups row, nothing is updated (as noted in Trac comment:16).
This uses
$user->user_login, and unslashes the posted email beforeis_email()so addresses with an apostrophe are accepted. Same change asattachment 26805.fix.diff by boonebgorges.
Tested on a local 7.1.4 multisite (subdirectory): before the change, saving
user2's profile as admin1 changed admin1's signups row; after it, user2's row
is updated and admin1's is untouched.
Trac ticket: https://core.trac.wordpress.org/ticket/26805
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code, with code-intruder (my own static analysis tool)
Model(s): Claude Opus, Claude Haiku
Used for: code-intruder flagged the call path and an AI review noticed the
undefined
$user_login. AI helped confirm the behavior on a local multisiteinstall (real POST to user-edit.php, checking wp_signups before/after) and
check the existing patch. I reviewed and tested the change myself.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.