Make WordPress Core

Opened 5 years ago

Last modified 5 years ago

#45498 reviewing defect (bug)

Wrong order of arguments in call_user_func() for Walker_Comment::start_el()

Reported by: milana_cap's profile milana_cap Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Comments Keywords: has-patch needs-unit-tests
Focuses: Cc:


Arguments order for rendering all types of comments is $comment, $depth, $args except for the custom callback:

call_user_func( $args['callback'], $comment, $args, $depth );

This causes every custom callback to throw an error when you use $args and $depth as you'd expect.

For example, comment_reply_link() inside callback can not be used like it's suppose to be used, like so:

comment_reply_link( array_merge( $args, array(
        'add_below' => 'div-comment',
        'depth'     => $depth,
        'max_depth' => $args['max_depth'],
        'before'    => '<div class="reply">',
        'after'     => '</div>'
) ) );

You need to replace $depth and $args, like so:

comment_reply_link( array_merge( $depth, array(
        'add_below' => 'div-comment',
        'depth'     => $args,
        'max_depth' => $depth['max_depth'],
        'before'    => '<div class="reply">',
        'after'     => '</div>'
) ) );

Attachments (1)

45498.patch (496 bytes) - added by milana_cap 5 years ago.

Download all attachments as: .zip

Change History (3)

5 years ago

#1 @SergeyBiryukov
5 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 5.1
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#2 @pento
5 years ago

  • Keywords needs-unit-tests added
  • Milestone changed from 5.1 to Future Release

Patch needs review, particularly with consideration to if it's likely to break workarounds for this bug.

Unit tests would also be good.

Note: See TracTickets for help on using tickets.