WordPress.org

Ready to get started?Download WordPress

Forums

Confusing argument name in `get_comments_number` (6 posts)

  1. JoannesVermorel
    Member
    Posted 8 years ago #

    In comment-functions.php, the function declaration is get_comments_number($comment_id). But obviouly, by looking at the code is seems that the meaning is $post_id.

  2. Joshua Sigar
    Member
    Posted 8 years ago #

    So, what's the problem?

    I haven't verified myself the values, but if commment's ID is the same as the corresponding post's ID, then everything seems to be in place, unless I miss something.

  3. Kafkaesqui

    Posted 8 years ago #

    It's just the name of the variable used for the argument that's passed to the function. It could be called $whatyoutalkinaboutwillis and still work the same.

  4. JoannesVermorel
    Member
    Posted 8 years ago #

    Yes, I totally agree that the code 100% functionnal. Nevertheless that's not a reason for leaving confusing names as such, in particular when it's easy to correct it.

    Extensibility is not only a matter of architecture, code readability is also an import factor.

  5. Joshua Sigar
    Member
    Posted 8 years ago #

    After looking at the wp_comments table, I realize you're right, Joannes.

    In that table, we have column comment_id and comment_post_id, and the parameter passed to that function ($comment_id) is matched against the comment_post_id.

    Unless someone looks deeper (which is supposed to be unnecessary), then the parameter name is indeed misleading. You could file a bug if you want.

  6. Kafkaesqui

    Posted 8 years ago #

    "Extensibility is not only a matter of architecture, code readability is also an import factor."

    A good point to make. If you had made it in the first post...

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.