Make WordPress Core

Opened 16 months ago

Closed 16 months ago

Last modified 16 months ago

#62169 closed defect (bug) (fixed)

Use strict comparison in wp_list_comments()

Reported by: deepakrohilla's profile deepakrohilla Owned by: deepakrohilla's profile deepakrohilla
Milestone: 6.7 Priority: normal
Severity: normal Version:
Component: Comments Keywords: has-patch
Focuses: coding-standards Cc:

Description (last modified by sabernhardt)

A strict comparison should be implemented in the wp-includes/comment-template.php file in wp_list_comments() on line 2291:
if ( $parsed_args['page'] !== $current_cpage || $parsed_args['per_page'] !== $current_per_page ) .

$parsed_args['page'] and $current_cpage, as well as $parsed_args['per_page'] and $current_per_page, both return integer values. I have not observed any of these variables returning a different return type.

Attachments (1)

stict-compare.JPG (32.5 KB) - added by deepakrohilla 16 months ago.

Download all attachments as: .zip

Change History (6)

#2 @sabernhardt
16 months ago

  • Component changed from General to Comments
  • Description modified (diff)
  • Focuses coding-standards added
  • Summary changed from A strict comparison should be implemented in the wp-includes/comment-template.php in wp_list_comments function to Use strict comparison in wp_list_comments()

#3 in reply to: ↑ description @SergeyBiryukov
16 months ago

  • Milestone changed from Awaiting Review to 6.7

Hi there, thanks for the ticket!

Replying to deepakrohilla:

$parsed_args['page'] and $current_cpage, as well as $parsed_args['per_page'] and $current_per_page, both return integer values. I have not observed any of these variables returning a different return type.

In my testing, both $current_cpage and $current_per_page are actually a string here, as returned by get_query_var(). Technically $parsed_args['page'] and $parsed_args['per_page'] can be a string too, depending on the type that was passed in, so this would need type casting on both sides for correct comparison.

#4 @SergeyBiryukov
16 months ago

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

In 59183:

Coding Standards: Use strict comparison in wp_list_comments().

Follow-up to [8962], [9296], [9424], [34735], [36157].

Props deepakrohilla, sabernhardt, aristath, poena, afercia, SergeyBiryukov.
Fixes #62169. See #61607.

@SergeyBiryukov commented on PR #7505:


16 months ago
#5

Thanks for the PR! Merged in r59183.

Note: See TracTickets for help on using tickets.