WordPress.org

Make WordPress Core

Ticket #8470: large-export-fix-no-indent.diff

File large-export-fix-no-indent.diff, 1.6 KB (added by tott, 9 years ago)

minor improvements against rev 10020 for export routine in terms of content flushing and memory consumption

  • wp-admin/includes/export.php

     
    3030
    3131$filename = 'wordpress.' . date('Y-m-d') . '.xml';
    3232
     33set_time_limit( 0 );
     34
    3335header('Content-Description: File Transfer');
    3436header("Content-Disposition: attachment; filename=$filename");
    3537header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
     
    187189 *
    188190 * @since unknown
    189191 */
    190 function wxr_post_taxonomy() {
     192function wxr_post_taxonomy() {   
    191193        $categories = get_the_category();
    192194        $tags = get_the_tags();
    193195        $the_list = '';
     
    262264                $wp_query->in_the_loop = true;  // Fake being in the loop.
    263265                // fetch 20 posts at a time rather than loading the entire table into memory
    264266                while ( $next_posts = array_splice($post_ids, 0, 20) ) {
     267
     268            // reset time limit
     269            set_time_limit( 0 );
     270            // unset wpdb->queries as this is growing with each query.
     271            unset($wpdb->queries);
     272            $wpdb->queries=array();
     273
    265274                        $where = "WHERE ID IN (".join(',', $next_posts).")";
    266275                        $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts $where ORDER BY post_date_gmt ASC");
    267276                                foreach ($posts as $post) {
     
    325334</wp:comment>
    326335<?php } } ?>
    327336        </item>
    328 <?php } } } ?>
     337<?php
     338          // free some memory
     339          unset( $comments );
     340          unset( $postmeta );
     341          unset( $post );
     342}
     343          // flush the collected data to the browser     
     344          flush();
     345          ob_flush();
     346          unset( $posts );
     347} } ?>
    329348</channel>
    330349</rss>
    331350<?php