Opened 4 years ago
Last modified 16 months ago
#40143 new defect (bug)
Comment template functions don't check for comment existence
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | |
Component: | Comments | Keywords: | has-patch needs-unit-tests |
Focuses: | Cc: |
Description
Discovered during debugging an issue with Circle Lite theme, which uses comment_text( true ) in kopa_comment_callback()
function.
That, while being an invalid usage (the function treats true
as a comment ID), causes an inconsistent behaviour, depending on the existence of the comment:
- If the comment with ID 1 exists, the function returns its text, as expected. That's obviously not what the author of the theme intended, but still the correct behaviour of the function.
- If the comment with ID 1 does not exist, the function returns the text of the current comment in the loop instead of an empty string. What happens is
get_comment( $comment_ID )
returns null (as expected), but then null is passed toget_comment_text()
, which treats it as the current comment.
After investigating more, it looks like most of comment template functions are either affected in a similar way or cause an undefined property notice when passed a non-existing comment ID. Let's bring some consistency here.
Attachments (1)
Change History (5)
Note: See
TracTickets for help on using
tickets.
40143.patch fixes the inconsistencies and adds a couple of tests, but needs more tests.
All existing comment tests pass.