From cd4fd77bebf5ff0274d05901f13f87251ddbb22e Mon Sep 17 00:00:00 2001 From: westi Date: Mon, 21 Dec 2009 15:26:57 +0000 Subject: [PATCH] Fix some notices in the importer when importing files from old WordPress versions or not fetching attachments. See #11484. Ensure that we check that a user is created for the username we specify and otherwise fallback to the current user See #10319. git-svn-id: http://svn.automattic.com/wordpress/trunk@12469 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/import/wordpress.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/wp-admin/import/wordpress.php b/wp-admin/import/wordpress.php index 83c90acff1..7723260673 100644 --- a/wp-admin/import/wordpress.php +++ b/wp-admin/import/wordpress.php @@ -60,8 +60,12 @@ class WP_Import { function get_tag( $string, $tag ) { global $wpdb; preg_match("|<$tag.*?>(.*?)|is", $string, $return); - $return = preg_replace('|^$|s', '$1', $return[1]); - $return = $wpdb->escape( trim( $return ) ); + if ( isset($return[1]) ) { + $return = preg_replace('|^$|s', '$1', $return[1]); + $return = $wpdb->escape( trim( $return ) ); + } else { + $return = ''; + } return $return; } @@ -190,8 +194,10 @@ class WP_Import { if ( !$user_id ) { $user_id = wp_create_user($new_author_name, wp_generate_password()); } - - $this->author_ids[$in_author_name] = $user_id; + + if ( !is_wp_error( $user_id ) ) { + $this->author_ids[$in_author_name] = $user_id; + } } // failsafe: if the user_id was invalid, default to the current user @@ -842,7 +848,8 @@ class WP_Import { break; case 2: check_admin_referer('import-wordpress'); - $result = $this->import( $_GET['id'], $_POST['attachments'] ); + $fetch_attachments = (!empty($_POST['attachments'])) ? true : false; + $result = $this->import( $_GET['id'], $fetch_attachments); if ( is_wp_error( $result ) ) echo $result->get_error_message(); break;