mirror of
https://github.com/e107inc/e107.git
synced 2025-08-05 14:17:49 +02:00
e_tree_model::multiFieldCmp() string sort fields
An untested oversight in e_tree_model::multiFieldCmp() where $sort_field could be a string has now been corrected. $sort_field now accepts a string to prevent infinite recursion. Fixes: #3044
This commit is contained in:
@@ -3480,8 +3480,18 @@ class e_tree_model extends e_front_model
|
||||
*/
|
||||
protected static function multiFieldCmp($row1, $row2, $sort_field, $sort_order = 1)
|
||||
{
|
||||
// Multiple sort fields
|
||||
if (is_array($sort_field))
|
||||
{
|
||||
$field = array_shift($sort_field);
|
||||
}
|
||||
// One sort field
|
||||
else
|
||||
{
|
||||
$field = $sort_field;
|
||||
$sort_field = [];
|
||||
}
|
||||
|
||||
$cmp = strnatcmp((string) $row1[$field], (string) $row2[$field]);
|
||||
if ($sort_order === -1 || $sort_order === 1) $cmp *= $sort_order;
|
||||
if ($cmp === 0 && count($sort_field) >= 1)
|
||||
|
Reference in New Issue
Block a user