Make WordPress Core

Opened 6 years ago

Closed 3 years ago

#21249 closed defect (bug) (fixed)

WP_List_Table::single_row_columns() needs to do an exact comparison

Reported by: Viper007Bond Owned by: wonderboymusic
Milestone: 4.4 Priority: normal
Severity: normal Version:
Component: Administration Keywords: has-patch dev-feedback
Focuses: Cc:


If for whatever reason you pass a column ID of 0 when dealing with a list table, WordPress thinks it's a checkbox column because of the loose comparison, i.e. == instead of ===.

Since I don't see why passing a number instead of a string shouldn'r be allowed, attached is a patch.

Attachments (1)

21249.patch (480 bytes) - added by Viper007Bond 6 years ago.

Download all attachments as: .zip

Change History (10)

6 years ago

#1 @scribu
6 years ago

  • Keywords reporter-feedback added

Are you saying 'cb' == 0 evals to true?

#2 @scribu
6 years ago

  • Keywords reporter-feedback removed

D'oh. Yes, it does. Seems PHP's type coercion is at least as treacherous as the one in JavaScript.

#3 @kurtpayne
6 years ago

  • Cc kurtpayne added
  • Keywords needs-testing removed
  • Milestone changed from Awaiting Review to 3.4.3

I can reproduce the original bug. The patch looks good.

#4 @nacin
6 years ago

  • Milestone changed from 3.4.3 to 3.5

Would if ( 'cb' == $column_key ) in print_column_headers() also be affected?

#5 @Viper007Bond
6 years ago

Seems like it would be affected, yes.

I can't test though because I don't remember exactly what I was working on at the time other than maybe I was creating columns programically using a numeric array.

#6 @nacin
6 years ago

  • Milestone changed from 3.5 to Future Release

I'm going to go with a column ID of "0" being invalid and punt this until we are able to fix it everywhere.

#7 @chriscct7
3 years ago

  • Keywords dev-feedback added
  • Priority changed from lowest to normal
  • Severity changed from trivial to normal

#8 @wonderboymusic
3 years ago

  • Milestone changed from Future Release to 4.4
  • Owner set to wonderboymusic
  • Status changed from new to assigned

#9 @wonderboymusic
3 years ago

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

In 34383:

List Tables: when comparing string literals (non-numeric in nature) against vars, strict comparison can/should be used.

Props wonderboymusic, Viper007Bond.
Fixes #21249.

Note: See TracTickets for help on using tickets.