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
This commit is contained in:
Felix Arntz 2017-04-07 13:14:36 +00:00
parent 3ca0673036
commit 4fbac9b3a7
2 changed files with 5 additions and 8 deletions

View File

@ -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.' ) );

View File

@ -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;