From 4fbac9b3a7b74c81a6bd6f739b262dea698b5ff4 Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Fri, 7 Apr 2017 13:14:36 +0000 Subject: [PATCH] Multisite: Partially revert [40295]. [40295] removed the restriction of a minimum amount of characters for new site names, which could cause unexpected behavior. That changeset is reverted here with the exception of the removal of the `is_super_admin()` check, which can safely be omitted. A new filter for the minimum site name length will be introduced later to be able to modify that behavior. See #39676, #37616. git-svn-id: https://develop.svn.wordpress.org/trunk@40391 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/ms-functions.php | 4 ++++ tests/phpunit/tests/multisite/wpmuValidateBlogSignup.php | 9 +-------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/wp-includes/ms-functions.php b/src/wp-includes/ms-functions.php index a562cdf241..9df86cfbde 100644 --- a/src/wp-includes/ms-functions.php +++ b/src/wp-includes/ms-functions.php @@ -577,6 +577,10 @@ function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) { if ( in_array( $blogname, $illegal_names ) ) $errors->add('blogname', __( 'That name is not allowed.' ) ); + if ( strlen( $blogname ) < 4 ) { + $errors->add('blogname', __( 'Site name must be at least 4 characters.' ) ); + } + // do not allow users to create a blog 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.' ) ); diff --git a/tests/phpunit/tests/multisite/wpmuValidateBlogSignup.php b/tests/phpunit/tests/multisite/wpmuValidateBlogSignup.php index 126702f969..3659efc115 100755 --- a/tests/phpunit/tests/multisite/wpmuValidateBlogSignup.php +++ b/tests/phpunit/tests/multisite/wpmuValidateBlogSignup.php @@ -64,6 +64,7 @@ class Tests_Multisite_WpmuValidateBlogSignup extends WP_UnitTestCase { array( '12345678', 'Site names must not consist of numbers only.' ), array( self::$existing_blog_name, 'Site names must not collide with an existing site name.' ), array( self::$existing_user_login, 'Site names must not collide with an existing user login.' ), + array( 'foo', 'Site names must at least contain 4 characters.' ), ); $illegal_names = get_site_option( 'illegal_names' ); @@ -85,14 +86,6 @@ class Tests_Multisite_WpmuValidateBlogSignup extends WP_UnitTestCase { $result = wpmu_validate_blog_signup( self::$existing_user_login, 'Foo Site Title', get_userdata( self::$existing_user_id ) ); $this->assertEmpty( $result['errors']->get_error_codes() ); } - - /** - * @ticket 39676 - */ - public function test_validate_short_blogname() { - $result = wpmu_validate_blog_signup( 'foo', 'Foo Site Title', get_userdata( self::$super_admin_id ) ); - $this->assertEmpty( $result['errors']->get_error_codes() ); - } } endif;