Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#62169 closed defect (bug) (fixed)

Use strict comparison in wp_list_comments()

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

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 2 years ago.

Download all attachments as: .zip

Change History (6)

#2 @sabernhardt
2 years ago

  • Component GeneralComments
  • Description modified (diff)
  • Focuses coding-standards added
  • Summary A strict comparison should be implemented in the wp-includes/comment-template.php in wp_list_comments functionUse strict comparison in wp_list_comments()

#3 in reply to: ↑ description @SergeyBiryukov
2 years ago

  • Milestone Awaiting Review6.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
2 years ago

  • Resolutionfixed
  • Status assignedclosed

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:


2 years ago
#5

Thanks for the PR! Merged in r59183.

Note: See TracTickets for help on using tickets.