wordpress-develop icon indicating copy to clipboard operation
wordpress-develop copied to clipboard

Ticket/17904

Open petitphp opened this issue 3 years ago • 4 comments

This PR implement changes proposed in ticket 17904#comment:64

The goal is to align how single and multisite check the validity of a username.

Changes in PR :

  • Update validate_username() to include all restrictions from multisite,
  • Introduce new function is_username_reserved(), this function performs the wp_signups query for existing username that was previously done in wpmu_validate_user_signup(),
  • Introduce new function wp_validate_user_login(), that acts as a wrapper calling validate_username(), username_exists() and is_username_reserved(),
  • Update codebase to use the new wp_validate_user_login() where applicable and remove code that was merge in validate_username(),
  • Update User REST endpoint following the refactoring of validate_username(),
  • Update wpmu_validate_blog_signup() to allow dashes in blogname.

Changes not in PR :

  • Change username_exists() to accept a second parameter $check_reserved = true, this seem like a tricky change to me. Currently the function will return either a user id matching the username or false. Returning a true when the username is reserved could break other code casting the return of username_exists() to int.

Trac ticket: https://core.trac.wordpress.org/ticket/17904


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.

petitphp avatar Aug 30 '22 14:08 petitphp

Thanks for the PR, I added a commit to fix a WPCS issue. It replaces current_time() with time(), as per WordPress Coding Standards.

audrasjb avatar Aug 30 '22 14:08 audrasjb

@dream-encode Thanks for taking the time to look at the PR. I've applied all your suggestions.

petitphp avatar Oct 03 '22 20:10 petitphp

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props petitphp, audrasjb, davidbaumwald, peterwilsoncc, rajinsharwar.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

github-actions[bot] avatar Feb 26 '24 23:02 github-actions[bot]

Test using WordPress Playground

The 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

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance, it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

github-actions[bot] avatar Feb 26 '24 23:02 github-actions[bot]