[wp-trac] [WordPress Trac] #49236: Use 'comment' instead of '' for the comment_type db field for comments
WordPress Trac
noreply at wordpress.org
Tue Aug 4 20:22:00 UTC 2020
#49236: Use 'comment' instead of '' for the comment_type db field for comments
-------------------------------------------------+-------------------------
Reporter: imath | Owner:
| SergeyBiryukov
Type: enhancement | Status: closed
Priority: normal | Milestone: 5.5
Component: Comments | Version: 5.4
Severity: normal | Resolution: fixed
Keywords: has-patch early commit has-dev-note | Focuses:
-------------------------------------------------+-------------------------
Comment (by imath):
Hi @westonruter
Thanks a lot for your comment. I understand your concern. I'm fine with
what you're suggesting, but I wonder if we could find a way that would
require as less as possible database sollicitation.
If it only concerns the `get_comment()` function what about doing :
{{{
function get_comment( &$comment = null, $output = OBJECT ) {
// beginning of the code of the function
if ( ! $_comment ) {
return null;
}
if ( '' === $_comment->comment_type ) {
$_comment->comment_type = 'comment';
}
/**
* Fires after a comment is retrieved.
}}}
Otherwise, what about doing:
{{{
$comment_ids = $wpdb->get_col(
$wpdb->prepare(
"SELECT comment_ID
FROM {$wpdb->comments}
WHERE comment_type = ''
ORDER BY comment_ID DESC
LIMIT %d",
$comment_batch_size
)
);
$in_comment_ids = implode( ',', wp_parse_id_list( $comment_ids ) );
$wpdb->query(
$wpdb->prepare(
"UPDATE {$wpdb->comments}
SET comment_type = 'comment'
WHERE comment_ID IN ({$in_comment_ids})
)
);
clean_comment_cache( $comment_ids );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49236#comment:25>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list