mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
For large networks, show the latest registered blogs without paging to avoid expensive count queries. see #15170
git-svn-id: http://svn.automattic.com/wordpress/trunk@16137 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0f284db680
commit
e08e1bf63b
@ -32,6 +32,17 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
||||
$s = isset( $_REQUEST['s'] ) ? stripslashes( trim( $_REQUEST[ 's' ] ) ) : '';
|
||||
$like_s = esc_sql( like_escape( $s ) );
|
||||
|
||||
$large_network = false;
|
||||
// If the network is large and a search is not being performed, show only the latest blogs with no paging in order
|
||||
// to avoid expensive count queries.
|
||||
if ( !$s && ( get_blog_count() >= 10000 ) ) {
|
||||
if ( !isset($_REQUEST['orderby']) )
|
||||
$_GET['orderby'] = $_REQUEST['orderby'] = 'registered';
|
||||
if ( !isset($_REQUEST['order']) )
|
||||
$_GET['order'] = $_REQUEST['order'] = 'DESC';
|
||||
$large_network = true;
|
||||
}
|
||||
|
||||
$query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' ";
|
||||
|
||||
if ( isset( $_REQUEST['searchaction'] ) ) {
|
||||
@ -63,11 +74,16 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
||||
$order = ( isset( $_REQUEST['order'] ) && 'DESC' == strtoupper( $_REQUEST['order'] ) ) ? "DESC" : "ASC";
|
||||
$query .= $order;
|
||||
|
||||
$total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT( blog_id )', $query ) );
|
||||
// Don't do an unbounded count on large networks
|
||||
if ( ! $large_network )
|
||||
$total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT( blog_id )', $query ) );
|
||||
|
||||
$query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page ) . ", " . intval( $per_page );
|
||||
$this->items = $wpdb->get_results( $query, ARRAY_A );
|
||||
|
||||
if ( $large_network )
|
||||
$total = count($this->items);
|
||||
|
||||
$this->set_pagination_args( array(
|
||||
'total_items' => $total,
|
||||
'per_page' => $per_page,
|
||||
|
Loading…
Reference in New Issue
Block a user