From 6ebc6d05dff2217f5342ed77c073ee28d6500d63 Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Fri, 12 May 2023 09:08:50 +0100 Subject: [PATCH] Fix: SearchPane option ordering could give a deprecated warning if null data is present https://datatables.net/forums/discussion/76266 --- Editor/SearchPaneOptions.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Editor/SearchPaneOptions.php b/Editor/SearchPaneOptions.php index 8a61632..e209111 100644 --- a/Editor/SearchPaneOptions.php +++ b/Editor/SearchPaneOptions.php @@ -444,9 +444,20 @@ public function exec ( $field, $editor, $http, $fields, $leftJoinIn ) // Only sort if there was no SQL order field if ( ! $this->_order ) { usort( $out, function ( $a, $b ) { - return is_numeric($a['label']) && is_numeric($b['label']) ? - ($a['label']*1) - ($b['label']*1) : - strcmp( $a['label'], $b['label'] ); + $aLabel = $a['label']; + $bLabel = $b['label']; + + if ($aLabel === null) { + $aLabel = ''; + } + + if ($bLabel === null) { + $bLabel = ''; + } + + return is_numeric($aLabel) && is_numeric($bLabel) ? + ($aLabel*1) - ($bLabel*1) : + strcmp( $aLabel, $bLabel ); } ); }