Add checks for WP_Error. Props filosofo. see #4809

git-svn-id: http://svn.automattic.com/wordpress/trunk@6125 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan
2007-09-18 16:32:22 +00:00
parent f30cd7acec
commit 9bfccd6286
23 changed files with 151 additions and 29 deletions

View File

@@ -215,6 +215,8 @@ class MT_Import {
$post->post_author = $this->checkauthor($post->post_author); //just so that if a post already exists, new users are not created by checkauthor
$post_id = wp_insert_post($post);
if ( is_wp_error( $post_id ) )
return $post_id;
// Add categories.
if ( 0 != count($post->categories) ) {
@@ -291,7 +293,9 @@ class MT_Import {
} else if ( '--------' == $line ) {
// Finishing a post.
$context = '';
$this->save_post($post, $comments, $pings);
$result = $this->save_post($post, $comments, $pings);
if ( is_wp_error( $result ) )
return $result;
$post = new StdClass;
$comment = new StdClass();
$ping = new StdClass();
@@ -415,7 +419,9 @@ class MT_Import {
else
$this->file = get_attached_file($this->id);
$this->get_authors_from_post();
$this->process_posts();
$result = $this->process_posts();
if ( is_wp_error( $result ) )
return $result;
}
function dispatch() {
@@ -434,7 +440,9 @@ class MT_Import {
break;
case 2:
check_admin_referer('import-mt');
$this->import();
$result = $this->import();
if ( is_wp_error( $result ) )
echo $result->get_error_message();
break;
}
}