Make WordPress Core

Opened 21 months ago

Closed 18 months ago

Last modified 18 months ago

#57318 closed defect (bug) (fixed)

Coding Standards: Use strict comparison in wp-admin/includes/nav-menu.php

Reported by: jenilk's profile jenilk Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 6.3 Priority: normal
Severity: normal Version:
Component: Menus Keywords: has-patch needs-testing-info
Focuses: coding-standards Cc:

Description

Coding Standards: Use strict comparison in wp-admin/includes/nav-menu.php

Attachments (1)

57318.patch (1.7 KB) - added by jenilk 21 months ago.

Download all attachments as: .zip

Change History (6)

@jenilk
21 months ago

#1 follow-up: @johnbillion
21 months ago

  • Keywords has-patch needs-testing-info added
  • Severity changed from major to normal

Thanks for the patch @jenilk! Are all of these variables guaranteed to be of the same type? For example data coming in via $_POST may be a string, etc.

#2 in reply to: ↑ 1 @jenilk
21 months ago

Replying to johnbillion:

Thanks for the patch @jenilk! Are all of these variables guaranteed to be of the same type? For example data coming in via $_POST may be a string, etc.

@johnbillion - I made changes to the 4 places, and out of them, there are 2 places where the data is coming as $_POST for comparison. We can not be guaranteed of it will be of the same type(FYI we don't have declared variable with datatype specification).

#3 @SergeyBiryukov
18 months ago

  • Milestone changed from Awaiting Review to 6.3

Thanks for the patch!

In my testing, $_item_object_data['menu-item-db-id'] and $_POST['menu-item-db-id'][ $_key ] can be a string and need a type cast to int for correct comparison. The other two changes look good as is to me.

#4 @SergeyBiryukov
18 months ago

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

In 55593:

Coding Standards: Use strict comparison in wp-admin/includes/nav-menu.php.

Follow-up to [14248], [15008], [37748].

Props jenilk, johnbillion.
Fixes #57318.

#5 @dd32
18 months ago

In 55596:

Coding Standards: Use the correct variable.

Follow-up to [55593].

See #57318.

Note: See TracTickets for help on using tickets.