[wp-trac] [WordPress Trac] #40143: Comment template functions don't check for comment existence
WordPress Trac
noreply at wordpress.org
Mon Mar 13 16:59:37 UTC 2017
#40143: Comment template functions don't check for comment existence
----------------------------+----------------------------------------
Reporter: SergeyBiryukov | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 4.8
Component: Comments | Version:
Severity: normal | Keywords: has-patch needs-unit-tests
Focuses: |
----------------------------+----------------------------------------
Discovered during debugging an issue with Circle Lite theme, which uses
[https://themes.trac.wordpress.org/browser/circle-
lite/1.0.9/comments.php?marks=55#L42 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 to `get_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.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40143>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list