Skip to content

Commit

Permalink
fix: prevent null order parameter in spreadsheet table sorting
Browse files Browse the repository at this point in the history
- Add null coalescing operator to handle null order parameter
- Set default order to 'DESC' when order is not specified
- Validate and sanitize order parameter before use
- Improve code readability and prevent potential TypeError
  • Loading branch information
sectsect committed Dec 13, 2024
1 parent 6100e4f commit ed64e69
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions admin/class-recursivetable.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
);

// Sort column validation.
$order = $order ?? $default_order;
$orderby = isset( $allowed_orderby[ $orderby ] ) ? $orderby : $default_orderby;
$order = in_array( strtoupper( $order ), array( 'ASC', 'DESC' ), true ) ? strtoupper( $order ) : $default_order;

Expand Down

0 comments on commit ed64e69

Please sign in to comment.