Make WordPress Core

Opened 8 years ago

Last modified 5 days 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 has-unit-tests
Focuses: Cc:

Description

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:

<?php
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:

<?php
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 8 years ago.

Download all attachments as: .zip

Change History (4)

@milana_cap
8 years ago

#1 @SergeyBiryukov
8 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
7 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.

This ticket was mentioned in PR #12104 on WordPress/wordpress-develop by @sukhendu2002.


5 days ago
#3

  • Keywords has-unit-tests added; needs-unit-tests removed
Note: See TracTickets for help on using tickets.