From eb7a3d1a2fe759ee7a402b9a9799b83bae637d21 Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Fri, 17 Mar 2017 14:35:08 +0000 Subject: [PATCH] Multisite: Remove restriction of minimum site name length in `wpmu_validate_blog_signup()`. It is sometimes desirable to support shorter site names than 4 characters, therefore that restriction should be removed. It is still possible to manually enforce it by using the `wpmu_validate_blog_signup` filter. As a result of this change, another `is_super_admin()` call gets removed which affects the ongoing efforts of working on a network-wide role system. Props milindmore22. Fixes #39676. See #37616. git-svn-id: https://develop.svn.wordpress.org/trunk@40295 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/ms-functions.php | 3 --- .../tests/multisite/wpmuValidateBlogSignup.php | 12 ++++++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/wp-includes/ms-functions.php b/src/wp-includes/ms-functions.php index b2b37d599b..d1ebe8d47f 100644 --- a/src/wp-includes/ms-functions.php +++ b/src/wp-includes/ms-functions.php @@ -576,9 +576,6 @@ 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 && !is_super_admin() ) - $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 eee18ab119..126702f969 100755 --- a/tests/phpunit/tests/multisite/wpmuValidateBlogSignup.php +++ b/tests/phpunit/tests/multisite/wpmuValidateBlogSignup.php @@ -66,10 +66,6 @@ class Tests_Multisite_WpmuValidateBlogSignup extends WP_UnitTestCase { array( self::$existing_user_login, 'Site names must not collide with an existing user login.' ), ); - if ( ! is_super_admin() ) { - $data[] = array( 'foo', 'Site names must at least contain 4 characters.' ); - } - $illegal_names = get_site_option( 'illegal_names' ); if ( ! empty( $illegal_names ) ) { $data[] = array( array_shift( $illegal_names ), 'Illegal site names are not allowed.' ); @@ -89,6 +85,14 @@ 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;