Make WordPress Core


Ignore:
Timestamp:
09/18/2007 04:32:22 PM (18 years ago)
Author:
ryan
Message:

Add checks for WP_Error. Props filosofo. see #4809

File:
1 edited

Legend:

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

    r6026 r6125  
    251251        echo '<ol>';
    252252
    253         foreach ($this->posts as $post)
    254             $this->process_post($post);
     253        foreach ($this->posts as $post) {
     254            $result = $this->process_post($post);
     255            if ( is_wp_error( $result ) )
     256                return $result;
     257        }
    255258
    256259        echo '</ol>';
     
    304307            $post_parent = (int) $post_parent;
    305308            if ($parent = $this->posts_processed[$post_parent]) {
    306                 if (!$parent[1]) $this->process_post($parent[0]); // If not yet, process the parent first.
     309                if (!$parent[1]) {
     310                    $result = $this->process_post($parent[0]); // If not yet, process the parent first.
     311                    if ( is_wp_error( $result ) )
     312                        return $result;
     313                }
    307314                $post_parent = $parent[1]; // New ID of the parent;
    308315            }
     
    315322            $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'post_name', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt', 'guid', 'post_parent', 'menu_order', 'post_type');
    316323            $comment_post_ID = $post_id = wp_insert_post($postdata);
     324            if ( is_wp_error( $post_id ) )
     325                return $post_id;
    317326
    318327            // Memorize old and new ID.
     
    383392        $this->get_entries();
    384393        $this->process_categories();
    385         $this->process_posts();
     394        $result = $this->process_posts();
     395        if ( is_wp_error( $result ) )
     396            return $result;
    386397    }
    387398
     
    403414            case 2:
    404415                check_admin_referer('import-wordpress');
    405                 $this->import();
     416                $result = $this->import();
     417                if ( is_wp_error( $result ) )
     418                    echo $result->get_error_message();
    406419                break;
    407420        }
Note: See TracChangeset for help on using the changeset viewer.