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
This commit is contained in:
westi 2009-12-21 15:26:57 +00:00
parent c77de6f941
commit cd4fd77beb

View File

@ -60,8 +60,12 @@ class WP_Import {
function get_tag( $string, $tag ) {
global $wpdb;
preg_match("|<$tag.*?>(.*?)</$tag>|is", $string, $return);
$return = preg_replace('|^<!\[CDATA\[(.*)\]\]>$|s', '$1', $return[1]);
$return = $wpdb->escape( trim( $return ) );
if ( isset($return[1]) ) {
$return = preg_replace('|^<!\[CDATA\[(.*)\]\]>$|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;