Opened 19 years ago
Closed 19 years ago
#4863 closed defect (bug) (fixed)
Bug in get_comment function from wp-includes/comment.php
| Reported by: | BogdanGhervan | Owned by: | westi |
|---|---|---|---|
| Priority: | low | Milestone: | 2.3 |
| Component: | General | Version: | |
| Severity: | normal | Keywords: | get_comment comment.php |
| Cc: | Focuses: |
Description
In the get_comment function, this block of code:
$comment = (int) $comment;
if ( !isset($comment_cache[$comment]) ) {
$_comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment' LIMIT 1");
$comment_cache[$comment->comment_ID] = & $_comment;
}
Should change to:
$comment = (int) $comment;
if ( !isset($comment_cache[$comment]) ) {
$_comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment' LIMIT 1");
$comment_cache[$comment] = & $_comment;
}
$comment is an int, not an object, therefore the comment_ID property doesn't exist.
Change History (2)
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Hmm i suspect the intention here was for it to be $_comment->comment_ID that the cache was set on.
I think we need to check that the comment actually existed before we set the cache as well.