WordPress.org

Support

Support » Requests and Feedback » Confusing argument name in `get_comments_number`

Confusing argument name in `get_comments_number`

  • 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.

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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.

    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.

    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.

    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.

    “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…

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Confusing argument name in `get_comments_number`’ is closed to new replies.
Skip to toolbar