Export: Split the query for post authors in wxr_authors_list() into smaller chunks.
This aims to avoid a fatal error when attempting to export content on larger WP instances with a lot of data. Follow-up to [15961], [28731]. Props bor0, SirLouen, SergeyBiryukov. Fixes #63503. Built from https://develop.svn.wordpress.org/trunk@60632 git-svn-id: http://core.svn.wordpress.org/trunk@59968 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -406,18 +406,25 @@ function export_wp( $args = array() ) {
|
||||
|
||||
if ( ! empty( $post_ids ) ) {
|
||||
$post_ids = array_map( 'absint', $post_ids );
|
||||
$and = 'AND ID IN ( ' . implode( ', ', $post_ids ) . ')';
|
||||
$post_id_chunks = array_chunk( $post_ids, 20 );
|
||||
} else {
|
||||
$and = '';
|
||||
$post_id_chunks = array( array() );
|
||||
}
|
||||
|
||||
$authors = array();
|
||||
|
||||
foreach ( $post_id_chunks as $next_posts ) {
|
||||
$and = ! empty( $next_posts ) ? 'AND ID IN (' . implode( ', ', $next_posts ) . ')' : '';
|
||||
|
||||
$results = $wpdb->get_results( "SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_status != 'auto-draft' $and" );
|
||||
|
||||
foreach ( (array) $results as $result ) {
|
||||
$authors[] = get_userdata( $result->post_author );
|
||||
}
|
||||
}
|
||||
|
||||
$authors = array_filter( $authors );
|
||||
$authors = array_unique( $authors, SORT_REGULAR ); // Remove duplicate authors.
|
||||
|
||||
foreach ( $authors as $author ) {
|
||||
echo "\t<wp:author>";
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.9-alpha-60631';
|
||||
$wp_version = '6.9-alpha-60632';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
||||
Reference in New Issue
Block a user