[wp-trac] Re: [WordPress Trac] #8474: wordpress.com xml import
fatal error
WordPress Trac
wp-trac at lists.automattic.com
Wed Dec 3 15:54:47 GMT 2008
#8474: wordpress.com xml import fatal error
-----------------------+----------------------------------------------------
Reporter: jaredh123 | Owner:
Type: defect | Status: new
Priority: normal | Milestone: 2.7
Component: Import | Version: 2.6.1
Severity: normal | Resolution:
Keywords: |
-----------------------+----------------------------------------------------
Comment (by jaredh123):
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
--
Ticket URL: <http://trac.wordpress.org/ticket/8474#comment:1>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list