From 840859a32f5e7c6d579f1b643e99ed30d30d1fd7 Mon Sep 17 00:00:00 2001 From: Deltik Date: Fri, 23 Feb 2018 15:48:23 -0600 Subject: [PATCH] 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 --- e107_handlers/model_class.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e107_handlers/model_class.php b/e107_handlers/model_class.php index 0e58b7a87..1591ea712 100755 --- a/e107_handlers/model_class.php +++ b/e107_handlers/model_class.php @@ -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)