WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#18464 closed enhancement (fixed)

Relax network wildcard restrictions

Reported by: nacin Owned by: ryan
Milestone: 3.3 Priority: normal
Severity: normal Version:
Component: Network Admin Keywords:
Focuses: multisite Cc:

Description (last modified by nacin)

The network wildcard restrictions added in #15170 are useful for scaling up big networks.

But there's a very small number of networks that have greater than 10,000 blogs. Let's aim for the majority here and scrap the wildcard restrictions when we're dealing with smaller networks.

Here's a function we can use to replace our current ad-hoc checks against get_user_count() and get_blog_count():

function wp_is_large_network( $using = 'sites' ) {
	if ( 'users' == $using ) {
		$count = get_user_count();
		return apply_filters( 'wp_is_large_network', $count > 10000, 'users', $count );
	}

	$count = get_blog_count();
	return apply_filters( 'wp_is_large_network', $count > 10000, 'sites', $count );
}

Attachments (1)

18464.diff (3.4 KB) - added by PeteMall 3 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 nacin3 years ago

  • Description modified (diff)

PeteMall3 years ago

comment:2 PeteMall3 years ago

Related #18221.

comment:3 SergeyBiryukov3 years ago

if ( current_user_can( 'promote_users' ) ) 
	actions['addusers'] = __( 'Add existing user' );

That looks like something from another patch, no?

comment:4 shawnkhall3 years ago

  • Cc shawnkhall added

Works for me; both filters and new function. The new function could be used with advanced plugins, too, to help reduce unnecessary load.

comment:5 dougwrites3 years ago

  • Cc heymrpro@… added

Will this necessitate any changes in a contextual help tab? (re: comment 27 on #15170 ) Say, Network Setup?

comment:6 shawnkhall3 years ago

@dougwrites, No. This essentially just adds hookable handling while effectively emulating the exact same behavior as before. In other words: it makes it possible for the site manager to control what is a "large network" for the purposes of their own system, without relying solely on the "magic numbers" that are in place in the 3.0 to 3.2.1 releases. While an alternative is to use a conditional define for the limit, the method used here allows for a dynamic implementation. For example, say you only want to allow user 1 to have full scope (treat it as full access), while limiting others. This would do that pretty easily.

comment:7 ryan3 years ago

In class-wp-ms-users-list-table.php, why add trailing and leading '*' to the search term for small networks? This should be left for the user to do so that they can choose to get an exact match, or not. Searching for 'matt' and getting hundreds/thousands of '*matt*' matches is annoying.

comment:8 ryan3 years ago

  • Owner set to ryan
  • Resolution set to fixed
  • Status changed from new to closed

In [18871]:

Consolidate larg network criteria into wp_is_large_network(). Allow plugins to change this criteria via filter. Props PeteMall. fixes #18464

Note: See TracTickets for help on using tickets.