Make WordPress Core

Ticket #12619: wordpress.php.patch

File wordpress.php.patch, 3.0 KB (added by briancolinger, 15 years ago)
  • Sites/wordpress-trunk/wp-admin/import/wordpress.php

     
    168168
    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]) ) {
    174174                                // an existing user was selected in the dropdown list
     
    319319
    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                }
    324325        }
     
    340341
    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                }
    345347        }
     
    377379
    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                }
    382385        }
     
    494497                                        return $post_id;
    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 )
    500503                                        stick_post( $post_id );
     
    636639                                print '('.size_format(filesize($upload['file'])).')';
    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'];
    641650                        }
     
    665674                }
    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
    671682                // extract the file name and extension from the url
     
    705716
    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 )
    710722                        $this->url_remap[$headers['x-final-location']] = $upload['url'];
     
    713725
    714726        }
    715727
     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;
     736        }
     737
    716738        // sort by strlen, longest string first
    717739        function cmpr_strlen($a, $b) {
    718740                return strlen($b) - strlen($a);