From 2bbe1b7f40bda13fc6625aad6e3f1c0913566b39 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 31 Jan 2022 13:05:22 +0000 Subject: [PATCH] Docs: Add a comment to clarify the `username_exists()` check in `wpmu_validate_blog_signup()`. Creating a new site that matches an existing user's login name is not allowed, unless it's the user's own username. Follow-up to [https://mu.trac.wordpress.org/changeset/550 mu:550], [https://mu.trac.wordpress.org/changeset/1364 mu:1364]. Props henry.wright, joyously, swissspidy, SergeyBiryukov. Fixes #54326. git-svn-id: https://develop.svn.wordpress.org/trunk@52655 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/ms-functions.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/ms-functions.php b/src/wp-includes/ms-functions.php index 825495c538..4ba038cd00 100644 --- a/src/wp-includes/ms-functions.php +++ b/src/wp-includes/ms-functions.php @@ -682,7 +682,7 @@ function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) { $errors->add( 'blogname', sprintf( _n( 'Site name must be at least %s character.', 'Site name must be at least %s characters.', $minimum_site_name_length ), number_format_i18n( $minimum_site_name_length ) ) ); } - // Do not allow users to create a blog that conflicts with a page on the main blog. + // Do not allow users to create a site that conflicts with a page on the main blog. if ( ! is_subdomain_install() && $wpdb->get_var( $wpdb->prepare( 'SELECT post_name FROM ' . $wpdb->get_blog_prefix( $current_network->site_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) ) { $errors->add( 'blogname', __( 'Sorry, you may not use that site name.' ) ); } @@ -722,6 +722,10 @@ function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) { $errors->add( 'blogname', __( 'Sorry, that site already exists!' ) ); } + /* + * Do not allow users to create a site that matches an existing user's login name, + * unless it's the user's own username. + */ if ( username_exists( $blogname ) ) { if ( ! is_object( $user ) || ( is_object( $user ) && ( $user->user_login != $blogname ) ) ) { $errors->add( 'blogname', __( 'Sorry, that site is reserved!' ) );