Make WordPress Core

Opened 8 years ago

Closed 7 years ago

#38314 closed defect (bug) (fixed)

comment_text filter is passed inconsistent arguments

Reported by: danielbachhuber's profile danielbachhuber Owned by: johnbillion's profile johnbillion
Milestone: 4.8 Priority: normal
Severity: normal Version:
Component: Comments Keywords: has-patch needs-refresh
Focuses: docs Cc:


Only one argument is supplied in check_comment():

/** This filter is documented in wp-includes/comment-template.php */
$comment = apply_filters( 'comment_text', $comment );

However, three arguments are supplied in comment_text():

echo apply_filters( 'comment_text', $comment_text, $comment, $args );

The former should probably have two null values passed so error notices aren't triggered in callbacks hooking into the latter.

Attachments (2)

38314.diff (1.3 KB) - added by vaishu.agola27 8 years ago.
Changed Documentation of 'comment_text' filter and passed null values in check_comment()
38314-patch2.diff (1.3 KB) - added by vaishu.agola27 7 years ago.
empty array passed instead of null in $args

Download all attachments as: .zip

Change History (10)

#1 @boonebgorges
8 years ago

  • Owner set to drewapicture
  • Status changed from new to reviewing

Timeline, for reference:

  • [15957] $comment arg added to filter in comment_text()
  • [16357] 'comment_text' filter introduced in check_comment(). At this point, the two uses of the filter have already diverged
  • [25555] added the $args param to the filter in comment_text()

Passing null values in check_comment() would prevent against certain kinds of errors, but it also makes the filter documentation incorrect. @DrewAPicture do you have a suggestion for how to document this kind of problem? Can we say, eg,

 * @param null|WP_Comment $comment Comment object, if available. 

#2 @DrewAPicture
8 years ago

@boonebgorges I think we'd be fine adding the null type for parameter notations, sure.

#3 @boonebgorges
8 years ago

  • Keywords good-first-bug added
  • Owner drewapicture deleted

Thanks, @DrewAPicture !

Patch will need to include documentation to this effect.

8 years ago

Changed Documentation of 'comment_text' filter and passed null values in check_comment()

#4 @vaishu.agola27
8 years ago

  • Keywords has-patch added; needs-patch removed

#5 @johnbillion
8 years ago

  • Focuses docs added
  • Keywords good-first-bug removed
  • Milestone changed from Future Release to 4.8
  • Owner set to johnbillion

#6 @SergeyBiryukov
7 years ago

#24913 was marked as a duplicate.

#7 @SergeyBiryukov
7 years ago

  • Keywords needs-refresh added

Let's pass an empty array instead of null for $args, see comment:6:ticket:24913.

7 years ago

empty array passed instead of null in $args

#8 @rachelbaker
7 years ago

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

In 40664:

Comments: Update arguments passed to the 'comment_text' filter in check_comment().

Pass null or empty values for the missing $comment and $args parameters of the 'check_comment' filter in check_comment().

Props boonebgorges, vaishu.agola27, SergeyBiryukov.
Fixes #38314.

Note: See TracTickets for help on using tickets.