#8474 closed defect (bug) (fixed)
wordpress.com xml import fatal error
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | 2.7 | Priority: | normal |
| Severity: | normal | Version: | 2.6.1 |
| Component: | Import | Keywords: | |
| Focuses: | Cc: |
Description
self-hosted WP 2.6.5 is choking on a xml export file from wordpress.com, giving this error:
Fatal error: Cannot use object of type WP_Error as array in /home/moorep/public_html/blog/wp-admin/import/wordpress.php on line 465
which is this:
$tag_id = $tag_idterm_id?;
Seems to be related to empty CDATA tags like <![CDATA[]]>
lots of people having issues:
http://tinyurl.com/667aes
http://tinyurl.com/6af98n
attached is an export file if that helps
Attachments (1)
Change History (4)
#1
@
17 years ago
This is horrible probably (because I don't understand the WP_error object, and am a beginner with PHP, but what worked for me to fix it was change this: (wp-admin/import/wordpress.php lines 453 - 470)
// Add tags.
if (count($tags) > 0) {
$post_tags = array();
foreach ($tags as $tag) {
$slug = sanitize_term_field('slug', $tag, 0, 'post_tag', 'db');
$tag_obj = get_term_by('slug', $slug, 'post_tag');
$tag_id = 0;
if ( ! empty($tag_obj) )
$tag_id = $tag_obj->term_id;
if ( $tag_id == 0 ) {
$tag = $wpdb->escape($tag);
$tag_id = wp_insert_term($tag, 'post_tag');
$tag_id = $tag_id['term_id'];
}
$post_tags[] = intval($tag_id);
}
wp_set_post_tags($post_id, $post_tags);
}
with this:
// Add tags.
if (count($tags) > 0) {
$error = false;
$post_tags = array();
foreach ($tags as $tag) {
$slug = sanitize_term_field('slug', $tag, 0, 'post_tag', 'db');
$tag_obj = get_term_by('slug', $slug, 'post_tag');
$tag_id = 0;
if ( ! empty($tag_obj) )
$tag_id = $tag_obj->term_id;
if ( $tag_id == 0 ) {
$tag = $wpdb->escape($tag);
$tag_id = wp_insert_term($tag, 'post_tag');
if ( is_object( $tag_id ) ) {
$error = true;
} else {
$tag_id = $tag_id['term_id'];
}
}
if ( ! $error ) $post_tags[] = intval($tag_id);
}
if ( ! $error ) wp_set_post_tags($post_id, $post_tags);
}
which is just a rudimentary check for an object to break out of the if...
sorry, i don't know how to create a true diff
export file that won't import