Skip to content

Commit fdd766b

Browse files
committed
Check types of both data points before comparing in usort_reorder_callback. Fixes #166.
1 parent 4d9709b commit fdd766b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

php/class-list-table.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -1073,17 +1073,17 @@ function ( Snippet $snippet ) {
10731073
private function get_sort_direction( $a_data, $b_data ) {
10741074

10751075
// If the data is numeric, then calculate the ordering directly.
1076-
if ( is_numeric( $a_data ) ) {
1076+
if ( is_numeric( $a_data ) && is_numeric( $b_data ) ) {
10771077
return $a_data - $b_data;
10781078
}
10791079

10801080
// If only one of the data points is empty, then place it before the one which is not.
1081-
if ( '' === $a_data xor '' === $b_data ) {
1082-
return '' === $a_data ? 1 : -1;
1081+
if ( empty( $a_data ) xor empty( $b_data ) ) {
1082+
return empty( $a_data ) ? 1 : -1;
10831083
}
10841084

10851085
// Sort using the default string sort order if possible.
1086-
if ( is_string( $a_data ) ) {
1086+
if ( is_string( $a_data ) && is_string( $b_data ) ) {
10871087
return strcasecmp( $a_data, $b_data );
10881088
}
10891089

0 commit comments

Comments
 (0)