Make WordPress Core

Changeset 13735


Ignore:
Timestamp:
03/17/2010 04:56:10 PM (15 years ago)
Author:
ryan
Message:

WP importer fixes. Props briancolinger. fixes #12619

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/import/wordpress.php

    r13316 r13735  
    169169        // this will populate $this->author_ids with a list of author_names => user_ids
    170170
    171         foreach ( $_POST['author_in'] as $i => $in_author_name ) {
     171        foreach ( (array) $_POST['author_in'] as $i => $in_author_name ) {
    172172
    173173            if ( !empty($_POST['user_select'][$i]) ) {
     
    320320            $catarr = compact('category_nicename', 'category_parent', 'posts_private', 'links_private', 'posts_private', 'cat_name', 'category_description');
    321321
     322            print "<em>" . __( "Importing category $cat_name" ) . "</em><br />\n";
    322323            $cat_ID = wp_insert_category($catarr);
    323324        }
     
    341342            $tagarr = compact('slug', 'description');
    342343
     344            print "<em>" . __( "Importing tag $tag_name" ) . "</em><br />\n";
    343345            $tag_ID = wp_insert_term($tag_name, 'post_tag', $tagarr);
    344346        }
     
    378380            $termarr = compact('slug', 'description');
    379381
     382            print "<em>" . __( "Importing $term_name" ) . "</em><br />\n";
    380383            $term_ID = wp_insert_term($term_name, $this->get_tag( $c, 'wp:term_taxonomy' ), $termarr);
    381384        }
     
    495498            }
    496499            else {
    497                 printf(__('Importing post <em>%s</em>...'), stripslashes($post_title));
     500                printf(__('Importing post <em>%s</em>...') . "\n", stripslashes($post_title));
    498501                $comment_post_ID = $post_id = wp_insert_post($postdata);
    499502                if ( $post_id && $is_sticky == 1 )
     
    637640            }
    638641
     642            if ( 0 == filesize( $upload['file'] ) ) {
     643                print __( "Zero length file, deleting" ) . "\n";
     644                unlink( $upload['file'] );
     645                return;
     646            }
     647
    639648            if ( $info = wp_check_filetype($upload['file']) ) {
    640649                $postdata['post_mime_type'] = $info['type'];
     
    666675    }
    667676
    668     function fetch_remote_file($post, $url) {
     677    function fetch_remote_file( $post, $url ) {
     678        add_filter( 'http_request_timeout', array( &$this, 'bump_request_timeout' ) );
     679
    669680        $upload = wp_upload_dir($post['post_date']);
    670681
     
    706717        // keep track of the old and new urls so we can substitute them later
    707718        $this->url_remap[$url] = $upload['url'];
     719        $this->url_remap[$post['guid']] = $upload['url'];
    708720        // if the remote url is redirected somewhere else, keep track of the destination too
    709721        if ( $headers['x-final-location'] != $url )
     
    712724        return $upload;
    713725
     726    }
     727
     728    /**
     729     * Bump up the request timeout for http requests
     730     *
     731     * @param int $val
     732     * @return int
     733     */
     734    public function bump_request_timeout( $val ) {
     735        return 60;
    714736    }
    715737
Note: See TracChangeset for help on using the changeset viewer.