[wp-hackers] Will this generate bug?

louie alfred gomez harry07 at gmail.com
Tue Oct 31 01:57:32 GMT 2006


I originally posted this one at the support forums of wordpress and  *
spencerp <http://www.vindictivebastard.net/> *told** me that I can ask
here...

So here it is....

Hello, I add some lines at the function
wp_insert_comment()(/wp-includes/comment-
functions.php)

the original code was

function wp_insert_comment($commentdata) {
global $wpdb;
extract($commentdata);
if ( ! isset($comment_author_IP) )
$comment_author_IP = $_SERVER['REMOTE_ADDR'];
if ( ! isset($comment_date) )
$comment_date = current_time('mysql');
if ( ! isset($comment_date_gmt) )
$comment_date_gmt = gmdate('Y-m-d H:i:s', strtotime($comment_date) );
if ( ! isset($comment_parent) )
$comment_parent = 0;
if ( ! isset($comment_approved) )
$comment_approved = 1;
$result = $wpdb->query("INSERT INTO $wpdb->comments
(comment_post_ID, comment_author, comment_author_email, comment_author_url,
comment_author_IP, comment_date, comment_date_gmt, comment_content,
comment_approved, comment_agent, comment_type, comment_parent, user_id)
VALUES
('$comment_post_ID', '$comment_author', '$comment_author_email',
'$comment_author_url', '$comment_author_IP', '$comment_date',
'$comment_date_gmt', '$comment_content', '$comment_approved',
'$comment_agent', '$comment_type', '$comment_parent', '$user_id')
");
$id = $wpdb->insert_id;
if ( $comment_approved == 1) {
$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE
comment_post_ID = '$comment_post_ID' AND comment_approved = '1'");
$wpdb->query( "UPDATE $wpdb->posts SET comment_count = $count WHERE ID =
'$comment_post_ID'" );
}
return $id;
}

and here is the edited one

function wp_insert_comment($commentdata) {
global $wpdb;
extract($commentdata);
if ( ! isset($comment_author_IP) )
$comment_author_IP = $_SERVER['REMOTE_ADDR'];
if ( ! isset($comment_date) )
$comment_date = current_time('mysql');
if ( ! isset($comment_date_gmt) )
$comment_date_gmt = gmdate('Y-m-d H:i:s', strtotime($comment_date) );
if ( ! isset($comment_parent) )
$comment_parent = 0;
if ( ! isset($comment_approved) )
$comment_approved = 1;
if ($comment_post_ID == '32' or $comment_post_ID == '84')
$comment_approved = 0;
$result = $wpdb->query("INSERT INTO $wpdb->comments
(comment_post_ID, comment_author, comment_author_email, comment_author_url,
comment_author_IP, comment_date, comment_date_gmt, comment_content,
comment_approved, comment_agent, comment_type, comment_parent, user_id)
VALUES
('$comment_post_ID', '$comment_author', '$comment_author_email',
'$comment_author_url', '$comment_author_IP', '$comment_date',
'$comment_date_gmt', '$comment_content', '$comment_approved',
'$comment_agent', '$comment_type', '$comment_parent', '$user_id')
");
$id = $wpdb->insert_id;
if ( $comment_approved == 1) {
$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE
comment_post_ID = '$comment_post_ID' AND comment_approved = '1'");
$wpdb->query( "UPDATE $wpdb->posts SET comment_count = $count WHERE ID =
'$comment_post_ID'" );
}
return $id;
}

(I added these lines: if ($comment_post_ID == '32' or $comment_post_ID ==
'84')
$comment_approved = 0;)

Now, I just want to ask if this will generate bugs. You see, I want all
comments that would be posted with the post number 32 or 84 undergo comment
moderation. Thanks!


More information about the wp-hackers mailing list