[wp-trac] Re: [WordPress Trac] #6505: WordPress Simple Tagging
Import Problem
WordPress Trac
wp-trac at lists.automattic.com
Fri May 2 15:39:46 GMT 2008
#6505: WordPress Simple Tagging Import Problem
----------------------+-----------------------------------------------------
Reporter: Makawork | Owner: anonymous
Type: defect | Status: new
Priority: high | Milestone: 2.5.2
Component: General | Version: 2.5.1
Severity: major | Resolution:
Keywords: |
----------------------+-----------------------------------------------------
Changes (by na3s):
* version: => 2.5.1
* severity: normal => major
* milestone: 2.7 => 2.5.2
Comment:
I have spent some time trying to debug this, but cannot locate the source
of this issue. Within the function 'tag2post' the function
'wp_add_post_tags returns' false. The parameters being fed into this
function are $the_post and $the_tag, both of which seem to have no errors,
and the correct types (an integer and a string). I have a feeling it may
be an error somewhere in the file wp-includes/post.php, but have no way of
verifying this. Below is an alternate tag2post function I used while
attempting to debug this issue; it may be of use to someone.
{{{
function tag2post ( ) {
global $wpdb;
// get the tags and posts we imported in the last 2 steps
$posts = get_option('stpimp_posts');
$total = count($posts);
// start at one
$tags_added = 0;
//make a pretty scrollable boxy
echo '<div style="height:300px;width:auto;overflow:scroll;">';
echo '<strong><u>TOTAL:'.$total.'</u></strong><br />';
// loop through each post and add its tags to the db
foreach ( $posts as $this_post ) {
$the_post = (int) $this_post->post_id;
$the_tag = $wpdb->escape($this_post->tag_name);
//echo some data about each row.
$wtfoutput =
$tags_added."->|".$the_post."|<em>(".gettype($the_post).")</em>
|".$the_tag."|<em>(".gettype($the_tag).")</em>";
// try to add the tag to a broken function and output a
friendly status message.
if(wp_add_post_tags($the_post, $the_tag)) {
$wtfoutput .= ' <strong
style="color:#00ff00;">Success!</strong><br />'."\r\n";
} else {
$wtfoutput .= ' <strong
style="color:#ff0000;">Shitty.</strong><br />'."\r\n";
}
echo $wtfoutput;
$tags_added++;
}
echo "</div>";
if ($tags_added == $total) {
echo '<strong>COMPLETE!<strong>';
} else {
echo '<strong>Bad News...<strong>'.$tags_added.' !=
'.$total;
}
// that's it, all posts should be linked to their tags properly,
pending any errors we just spit out!
return $tags_added;
}
}}}
--
Ticket URL: <http://trac.wordpress.org/ticket/6505#comment:2>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list