[wp-trac] [WordPress Trac] #35624: Use of get_comment() function shows Notice

WordPress Trac noreply at wordpress.org
Fri Feb 5 19:16:32 UTC 2016

#35624: Use of get_comment() function shows Notice
 Reporter:  WisdmLabs     |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  4.4.3
Component:  Comments      |     Version:  4.4
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:

Comment (by d4z_c0nf):

 Replying to [comment:8 boonebgorges]:
 > Replying to [comment:7 d4z_c0nf]:
 > > Thanks @boonebgorges I see what you mean.
 > > So this way, when a {{{$replytoid}}} exists, you overwrite (well you
 set it) the global {{{$comment}}}.
 > > Isn't this a little weird? I mean a function which should just return
 a string also changes a global variable?
 > >
 > > I still think that since you already have the comment id
 ({{{$replytoid}}}) there's no sense to retrieve it again with
 {{{get_comment_ID()}}}. But most likely there's something I don't know ;)
 > >
 > > Thanks for looking into it. :)
 > I agree that this is not elegant software design (or, at least, it's not
 very transparent). But I assume that it was originally a conscious choice
 to overload the global here, so that template tags would be usable when
 rendering the rest of the form.
 > Your suggested fix for `comment_form_title()` would fix
 `comment_form_title()`, but wouldn't address any of the other uses of
 comment-template.php functions within the context of a comment reply form,
 such as the one (`get_comment_author_email_link()`) that prompted this
 ticket to be opened in the first place. By restoring the previous behavior
 - ie setting the global - we solve all of the problems at once.

 Yeah you're absolutely right about the template tags thing.
 My .. "I still think.." was just referring to that other point (in
 addition) => not using {{{get_comment_ID()}}} when you already have the
 ID. But I suppose it could make sense too because of the filter hook.

 Thanks for your time :)

Ticket URL: <https://core.trac.wordpress.org/ticket/35624#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list