Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#38170 closed defect (bug) (fixed)

get_comment_reply_link(): access to args field 'max_depth' even if not set?

Reported by: d4z_c0nf's profile d4z_c0nf Owned by: boonebgorges's profile boonebgorges
Milestone: 4.7 Priority: normal
Severity: normal Version: 4.6.1
Component: Comments Keywords:
Focuses: Cc:



if ( 0 == $args['depth'] || $args['max_depth'] <= $args['depth'] ) {

max_depth isn't a default argument while it should be ... right?

Change History (5)

#1 @boonebgorges
8 years ago

  • Milestone changed from Awaiting Review to 4.7
  • Owner set to boonebgorges
  • Status changed from new to assigned

Hi @d4z_c0nf - Thanks for the ticket!

Yes, I think you're right that there should be a default defined here. In practice, the function is generally used in the context of wp_list_comments(), which passes in its default 'max_depth' parameters. But it seems like a reasonable idea to have a sanity check here.

Introduced in [8878].

#2 @boonebgorges
8 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 38669:

Set default value of 'max_depth' in get_comment_reply_link().

Introduced in [8878].

Props d4z_c0nf.
Fixes #38170.

#3 @d4z_c0nf
8 years ago

Thanks @boonebgorges
yeah the comment walker passes the max_depth param to it (wp_list_comment arg).

To be totally honest, I'm not sure how much "optional" the get_comment_reply_link() $args parameter is.
With the default values (depth==max-depth==0) that function will just silently exit.

What I mean is that the function doesn't retrieve those params by itself so in order to have some kind of result those params must be passed (depth can be retrieved from the $GLOBALS - set by the walker, max_depth is options dependent and is set in wp_list_comments() ).

IMHO the doc should be improved mentioning that if you call the function(s) without specify those params, in custom walkers or wp_list_comments callback contexts, you'll get nothing :D

But maybe that's a totally different story.

Thanks again.

#4 @boonebgorges
8 years ago

To be totally honest, I'm not sure how much "optional" the get_comment_reply_link() $args parameter is.

Yes, I agree that it's only "optional" in the technical sense that you won't get an error if you omit it. If you have ideas for improving the documentation, please feel free to open an enhancement ticket. Thanks again for the contribution!

#5 @d4z_c0nf
8 years ago

Thanks to you @boonebgorges !

Note: See TracTickets for help on using tickets.