Make WordPress Core

Ticket #63503: 63503.patch

File 63503.patch, 1.3 KB (added by bor0, 17 months ago)
  • wp-admin/includes/export.php

     
    406406
    407407                if ( ! empty( $post_ids ) ) {
    408408                        $post_ids = array_map( 'absint', $post_ids );
    409                         $and      = 'AND ID IN ( ' . implode( ', ', $post_ids ) . ')';
     409                        $chunks   = array_chunk( $post_ids, 20 );
    410410                } else {
    411                         $and = '';
     411                        $chunks   = [[]];
    412412                }
    413413
    414414                $authors = array();
    415                 $results = $wpdb->get_results( "SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_status != 'auto-draft' $and" );
    416                 foreach ( (array) $results as $result ) {
    417                         $authors[] = get_userdata( $result->post_author );
     415
     416                foreach ( $chunks as $chunk ) {
     417                        $and = ! empty( $chunk ) ? 'AND ID IN (' . implode( ', ', $chunk ) . ')' : '';
     418                       
     419                        $results = $wpdb->get_results( "SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_status != 'auto-draft' $and" );
     420                       
     421                        foreach ( (array) $results as $result ) {
     422                                $authors[] = get_userdata( $result->post_author );
     423                        }
    418424                }
    419 
     425               
    420426                $authors = array_filter( $authors );
    421 
     427                $authors = array_unique( $authors, SORT_REGULAR ); // Remove duplicate authors
    422428                foreach ( $authors as $author ) {
    423429                        echo "\t<wp:author>";
    424430                        echo '<wp:author_id>' . (int) $author->ID . '</wp:author_id>';