Skip to content

Commit

Permalink
Fix: PHP 8.3 deprecation error for strcmp with a null second argu…
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanJard committed Jun 24, 2024
1 parent e3f951d commit 00441ce
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
17 changes: 14 additions & 3 deletions Editor/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,20 @@ public function exec($db)
// Only sort if there was no SQL order field
if (!$this->_order) {
usort($out, static 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);
});
}

Expand Down
17 changes: 14 additions & 3 deletions Editor/SearchBuilderOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,20 @@ public function exec($field, $editor, $http, $fields, $leftJoinIn)
// Only sort if there was no SQL order field
if (!$this->_order) {
usort($out, static 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);
});
}

Expand Down

0 comments on commit 00441ce

Please sign in to comment.