Make WordPress Core

Opened 8 months ago

Closed 4 months ago

#60475 closed defect (bug) (fixed)

Possible incorrect type for $comment_id in get_comment_author filter

Reported by: davidbinda's profile david.binda Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 6.6 Priority: normal
Severity: normal Version: 6.0
Component: Comments Keywords: has-patch
Focuses: Cc:

Description

After r52818 the $comment_id param of the get_comment_author filter, which is documented as numeric string, may be an int, in case a non-existing comment ID is passed to the get_comment_author function.

The topic has been briefly discussed in https://core.trac.wordpress.org/ticket/54379#comment:8 mentioning that the numeric string type is here for compatibility.

I'm attaching a patch containing a fix for the issue, as well as a PHPUnit test demonstrating the behaviour.

Attachments (1)

60475.diff (3.3 KB) - added by david.binda 8 months ago.

Download all attachments as: .zip

Change History (4)

@david.binda
8 months ago

#1 @Presskopp
8 months ago

  • Keywords has-patch added

#2 @SergeyBiryukov
4 months ago

  • Milestone changed from Awaiting Review to 6.6

#3 @SergeyBiryukov
4 months ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 58335:

Comments: Ensure the correct comment ID type is passed to get_comment_author.

The $comment_id parameter of the get_comment_author filter is documented as a numeric string, however in case a non-existing comment ID is passed to the get_comment_author() function, it could be an integer instead.

This commit resolves the issue and adds a PHPUnit test demonstrating the behavior.

Includes updating get_comment_author_url() unit tests for consistency.

Follow-up to [41127], [52818].

Props david.binda.
Fixes #60475.

Note: See TracTickets for help on using tickets.