Repository navigation
Users: Record and display UTC timestamp when a user's password is set or changed - #16344
rubenwoudsma wants to merge 2 commits into
Conversation
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. |
|
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:
|
Summary
Implements Trac #66881 by recording a policy-neutral UTC Unix timestamp (
password_last_changeduser meta) whenever a user's primary password is confirmed saved via Core APIs, displaying a localized read-onlyLast changeddate under Account Management onprofile.php/user-edit.php, and exporting the timestamp in the native WordPress User Personal Data Exporter.Key Details
src/wp-includes/user.php,src/wp-includes/pluggable.php):wp_update_password_last_changed( $user_id )(guarded by thewp_should_update_password_last_changedfilter) and invokes it only after confirmed$wpdb->userspersistence inwp_insert_user()(initial password creation andwp_update_user()/ directwp_insert_user()password updates) andwp_set_password()(explicit sets andreset_password()).wp_update_user()validation errors or abortedwp_pre_insert_user_datasaves wheredo_action( 'wp_set_password' )has already fired) leavepassword_last_changedunchanged while keeping existingwp_set_passwordhook behavior intact.src/wp-includes/user.php):wp_update_password_last_changed()viawp_should_update_password_last_changed(inside atry / finallyblock) whenwp_authenticate_username_password()orwp_authenticate_email_password()transparently upgrades an existing password hash viawp_password_needs_rehash(), ensuring algorithm/cost upgrades at sign-in never falsify when the user actually changed their password.src/wp-admin/user-edit.php):Last changed: <localized date>(wp_date( __( 'F j, Y' ), $password_last_changed )) beneath Set New Password whenpassword_last_changed > 0, hidden when no timestamp has been recorded.src/wp-includes/user.php):User Password Last Changed(Y-m-d H:i:sUTC, matchingUser Registration Date) inwp_user_personal_data_exporter()when recorded, and omits it when absent.tests/phpunit/tests/user/wpUpdatePasswordLastChanged.php,tests/phpunit/tests/user.php):wp_insert_user()creation and direct updates, empty-password/invalid-ID handling,wp_update_user()(profile-only edits, successful password changes, and rejected updates preserving bothuser_passandpassword_last_changed),wp_set_password(),reset_password(), transparent legacy$P$hash upgrades during username and email authentication, andwp_user_personal_data_exporter().Trac ticket: https://core.trac.wordpress.org/ticket/66881
Testing Instructions
wp-admin/profile.php) for an existing account prior to changing its password and confirm no fabricatedLast changed:line is shown.Last changed: <today's localized date>appears beneath Set New Password.User Password Last Changedis included in the User group.Use of AI Tools
AI assistance: Yes
Tool(s): Antigravity, ChatGPT
Model(s): Gemini, GPT
Used for: Code-path analysis (including
wp_password_needs_rehash()login interaction and post-persistence ordering inwp_update_user()), drafting the implementation and PHPUnit test cases, 4-eyes review, and verifying Coding Standards / PHPStan / PHPUnit checks. Reviewed and directed by me (@rubenwoudsma/rubenw).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.